Deleted Added
full compact
qlnx_ioctl.c (317116) qlnx_ioctl.c (318659)
1/*
2 * Copyright (c) 2017-2018 Cavium, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *

--- 18 unchanged lines hidden (view full) ---

27
28
29/*
30 * File: qlnx_ioctl.c
31 * Author : David C Somayajulu, Qlogic Corporation, Aliso Viejo, CA 92656.
32 */
33
34#include <sys/cdefs.h>
1/*
2 * Copyright (c) 2017-2018 Cavium, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *

--- 18 unchanged lines hidden (view full) ---

27
28
29/*
30 * File: qlnx_ioctl.c
31 * Author : David C Somayajulu, Qlogic Corporation, Aliso Viejo, CA 92656.
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: stable/11/sys/dev/qlnx/qlnxe/qlnx_ioctl.c 316485 2017-04-04 06:16:59Z davidcs $");
35__FBSDID("$FreeBSD: stable/11/sys/dev/qlnx/qlnxe/qlnx_ioctl.c 318659 2017-05-22 19:28:38Z davidcs $");
36
37#include "qlnx_os.h"
38#include "bcm_osal.h"
39
40#include "reg_addr.h"
41#include "ecore_gtt_reg_addr.h"
42#include "ecore.h"
43#include "ecore_chain.h"

--- 72 unchanged lines hidden (view full) ---

116 }
117
118 ecore_dbg_set_app_ver(ecore_dbg_get_fw_func_ver());
119
120 p_hwfn = &ha->cdev.hwfns[hwfn_index];
121 p_ptt = ecore_ptt_acquire(p_hwfn);
122
123 if (!p_ptt) {
36
37#include "qlnx_os.h"
38#include "bcm_osal.h"
39
40#include "reg_addr.h"
41#include "ecore_gtt_reg_addr.h"
42#include "ecore.h"
43#include "ecore_chain.h"

--- 72 unchanged lines hidden (view full) ---

116 }
117
118 ecore_dbg_set_app_ver(ecore_dbg_get_fw_func_ver());
119
120 p_hwfn = &ha->cdev.hwfns[hwfn_index];
121 p_ptt = ecore_ptt_acquire(p_hwfn);
122
123 if (!p_ptt) {
124 QL_DPRINT1(ha, (ha->pci_dev, "%s : ecore_ptt_acquire failed\n",
125 __func__));
124 QL_DPRINT1(ha,"ecore_ptt_acquire failed\n");
126 return (rval);
127 }
128
129 if ((rval = ecore_dbg_grc_dump(p_hwfn, p_ptt,
130 ha->grcdump[hwfn_index],
131 (ha->grcdump_size[hwfn_index] >> 2),
132 num_dumped_dwords)) == DBG_STATUS_OK) {
133 rval = 0;
134 ha->grcdump_taken = 1;
135 } else
125 return (rval);
126 }
127
128 if ((rval = ecore_dbg_grc_dump(p_hwfn, p_ptt,
129 ha->grcdump[hwfn_index],
130 (ha->grcdump_size[hwfn_index] >> 2),
131 num_dumped_dwords)) == DBG_STATUS_OK) {
132 rval = 0;
133 ha->grcdump_taken = 1;
134 } else
136 QL_DPRINT1(ha, (ha->pci_dev,
137 "%s : ecore_dbg_grc_dump failed [%d, 0x%x]\n",
138 __func__, hwfn_index, rval));
135 QL_DPRINT1(ha,"ecore_dbg_grc_dump failed [%d, 0x%x]\n",
136 hwfn_index, rval);
139
140 ecore_ptt_release(p_hwfn, p_ptt);
141
142 return (rval);
143}
144
145static void
146qlnx_get_grc_dump_size(qlnx_host_t *ha, qlnx_grcdump_t *grcdump)

--- 25 unchanged lines hidden (view full) ---

172
173 rval = qlnx_grc_dump(ha, &dwords, i);
174
175 if (rval)
176 break;
177
178 grcdump->grcdump_dwords[i] = dwords;
179
137
138 ecore_ptt_release(p_hwfn, p_ptt);
139
140 return (rval);
141}
142
143static void
144qlnx_get_grc_dump_size(qlnx_host_t *ha, qlnx_grcdump_t *grcdump)

--- 25 unchanged lines hidden (view full) ---

170
171 rval = qlnx_grc_dump(ha, &dwords, i);
172
173 if (rval)
174 break;
175
176 grcdump->grcdump_dwords[i] = dwords;
177
180 QL_DPRINT1(ha, (ha->pci_dev, "%s: grcdump_dwords[%d] = 0x%x\n",
181 __func__, i, dwords));
178 QL_DPRINT1(ha,"grcdump_dwords[%d] = 0x%x\n", i, dwords);
182
183 rval = copyout(ha->grcdump[i], grcdump->grcdump[i],
184 ha->grcdump_size[i]);
185
186 if (rval)
187 break;
188
189 ha->grcdump_dwords[i] = 0;

--- 18 unchanged lines hidden (view full) ---

208 }
209
210 ecore_dbg_set_app_ver(ecore_dbg_get_fw_func_ver());
211
212 p_hwfn = &ha->cdev.hwfns[hwfn_index];
213 p_ptt = ecore_ptt_acquire(p_hwfn);
214
215 if (!p_ptt) {
179
180 rval = copyout(ha->grcdump[i], grcdump->grcdump[i],
181 ha->grcdump_size[i]);
182
183 if (rval)
184 break;
185
186 ha->grcdump_dwords[i] = 0;

--- 18 unchanged lines hidden (view full) ---

205 }
206
207 ecore_dbg_set_app_ver(ecore_dbg_get_fw_func_ver());
208
209 p_hwfn = &ha->cdev.hwfns[hwfn_index];
210 p_ptt = ecore_ptt_acquire(p_hwfn);
211
212 if (!p_ptt) {
216 QL_DPRINT1(ha, (ha->pci_dev,
217 "%s : ecore_ptt_acquire failed\n", __func__));
213 QL_DPRINT1(ha,"ecore_ptt_acquire failed\n");
218 return (rval);
219 }
220
221 if ((rval = ecore_dbg_idle_chk_dump(p_hwfn, p_ptt,
222 ha->idle_chk[hwfn_index],
223 (ha->idle_chk_size[hwfn_index] >> 2),
224 num_dumped_dwords)) == DBG_STATUS_OK) {
225 rval = 0;
226 ha->idle_chk_taken = 1;
227 } else
214 return (rval);
215 }
216
217 if ((rval = ecore_dbg_idle_chk_dump(p_hwfn, p_ptt,
218 ha->idle_chk[hwfn_index],
219 (ha->idle_chk_size[hwfn_index] >> 2),
220 num_dumped_dwords)) == DBG_STATUS_OK) {
221 rval = 0;
222 ha->idle_chk_taken = 1;
223 } else
228 QL_DPRINT1(ha, (ha->pci_dev,
229 "%s : ecore_dbg_idle_chk_dump failed [%d, 0x%x]\n",
230 __func__, hwfn_index, rval));
224 QL_DPRINT1(ha,"ecore_dbg_idle_chk_dump failed [%d, 0x%x]\n",
225 hwfn_index, rval);
231
232 ecore_ptt_release(p_hwfn, p_ptt);
233
234 return (rval);
235}
236
237static void
238qlnx_get_idle_chk_size(qlnx_host_t *ha, qlnx_idle_chk_t *idle_chk)

--- 27 unchanged lines hidden (view full) ---

266
267 rval = qlnx_idle_chk(ha, &dwords, i);
268
269 if (rval)
270 break;
271
272 idle_chk->idle_chk_dwords[i] = dwords;
273
226
227 ecore_ptt_release(p_hwfn, p_ptt);
228
229 return (rval);
230}
231
232static void
233qlnx_get_idle_chk_size(qlnx_host_t *ha, qlnx_idle_chk_t *idle_chk)

--- 27 unchanged lines hidden (view full) ---

261
262 rval = qlnx_idle_chk(ha, &dwords, i);
263
264 if (rval)
265 break;
266
267 idle_chk->idle_chk_dwords[i] = dwords;
268
274 QL_DPRINT1(ha, (ha->pci_dev, "%s: idle_chk_dwords[%d] = 0x%x\n",
275 __func__, i, dwords));
269 QL_DPRINT1(ha,"idle_chk_dwords[%d] = 0x%x\n", i, dwords);
276
277 rval = copyout(ha->idle_chk[i], idle_chk->idle_chk[i],
278 ha->idle_chk_size[i]);
279
280 if (rval)
281 break;
282
283 ha->idle_chk_dwords[i] = 0;

--- 10 unchanged lines hidden (view full) ---

294 struct ecore_hwfn *p_hwfn;
295 struct ecore_ptt *p_ptt;
296 uint32_t num_dwords = 0;
297
298 p_hwfn = &ha->cdev.hwfns[hwfn_index];
299 p_ptt = ecore_ptt_acquire(p_hwfn);
300
301 if (!p_ptt) {
270
271 rval = copyout(ha->idle_chk[i], idle_chk->idle_chk[i],
272 ha->idle_chk_size[i]);
273
274 if (rval)
275 break;
276
277 ha->idle_chk_dwords[i] = 0;

--- 10 unchanged lines hidden (view full) ---

288 struct ecore_hwfn *p_hwfn;
289 struct ecore_ptt *p_ptt;
290 uint32_t num_dwords = 0;
291
292 p_hwfn = &ha->cdev.hwfns[hwfn_index];
293 p_ptt = ecore_ptt_acquire(p_hwfn);
294
295 if (!p_ptt) {
302 QL_DPRINT1(ha, (ha->pci_dev,
303 "%s: ecore_ptt_acquire [%d, 0x%x]failed\n",
304 __func__, hwfn_index, cmd));
296 QL_DPRINT1(ha, "ecore_ptt_acquire [%d, 0x%x]failed\n",
297 hwfn_index, cmd);
305 return (0);
306 }
307
308 switch (cmd) {
309
310 case QLNX_MCP_TRACE:
311 rval = ecore_dbg_mcp_trace_get_dump_buf_size(p_hwfn,
312 p_ptt, &num_dwords);

--- 16 unchanged lines hidden (view full) ---

329
330 case QLNX_FW_ASSERTS:
331 rval = ecore_dbg_fw_asserts_get_dump_buf_size(p_hwfn,
332 p_ptt, &num_dwords);
333 break;
334 }
335
336 if (rval != DBG_STATUS_OK) {
298 return (0);
299 }
300
301 switch (cmd) {
302
303 case QLNX_MCP_TRACE:
304 rval = ecore_dbg_mcp_trace_get_dump_buf_size(p_hwfn,
305 p_ptt, &num_dwords);

--- 16 unchanged lines hidden (view full) ---

322
323 case QLNX_FW_ASSERTS:
324 rval = ecore_dbg_fw_asserts_get_dump_buf_size(p_hwfn,
325 p_ptt, &num_dwords);
326 break;
327 }
328
329 if (rval != DBG_STATUS_OK) {
337 QL_DPRINT1(ha, (ha->pci_dev, "%s : cmd = 0x%x failed [0x%x]\n",
338 __func__, cmd, rval));
330 QL_DPRINT1(ha,"cmd = 0x%x failed [0x%x]\n", cmd, rval);
339 num_dwords = 0;
340 }
341
342 ecore_ptt_release(p_hwfn, p_ptt);
343
344 return ((num_dwords * sizeof (uint32_t)));
345}
346

--- 17 unchanged lines hidden (view full) ---

364 int rval = -1;
365 struct ecore_hwfn *p_hwfn;
366 struct ecore_ptt *p_ptt;
367 uint32_t num_dwords = 0;
368 void *buffer;
369
370 buffer = qlnx_zalloc(trace->size[hwfn_index]);
371 if (buffer == NULL) {
331 num_dwords = 0;
332 }
333
334 ecore_ptt_release(p_hwfn, p_ptt);
335
336 return ((num_dwords * sizeof (uint32_t)));
337}
338

--- 17 unchanged lines hidden (view full) ---

356 int rval = -1;
357 struct ecore_hwfn *p_hwfn;
358 struct ecore_ptt *p_ptt;
359 uint32_t num_dwords = 0;
360 void *buffer;
361
362 buffer = qlnx_zalloc(trace->size[hwfn_index]);
363 if (buffer == NULL) {
372 QL_DPRINT1(ha, (ha->pci_dev,
373 "%s: qlnx_zalloc [%d, 0x%x]failed\n",
374 __func__, hwfn_index, trace->cmd));
364 QL_DPRINT1(ha,"qlnx_zalloc [%d, 0x%x]failed\n",
365 hwfn_index, trace->cmd);
375 return (ENXIO);
376 }
377 ecore_dbg_set_app_ver(ecore_dbg_get_fw_func_ver());
378
379 p_hwfn = &ha->cdev.hwfns[hwfn_index];
380 p_ptt = ecore_ptt_acquire(p_hwfn);
381
382 if (!p_ptt) {
366 return (ENXIO);
367 }
368 ecore_dbg_set_app_ver(ecore_dbg_get_fw_func_ver());
369
370 p_hwfn = &ha->cdev.hwfns[hwfn_index];
371 p_ptt = ecore_ptt_acquire(p_hwfn);
372
373 if (!p_ptt) {
383 QL_DPRINT1(ha, (ha->pci_dev,
384 "%s: ecore_ptt_acquire [%d, 0x%x]failed\n",
385 __func__, hwfn_index, trace->cmd));
374 QL_DPRINT1(ha, "ecore_ptt_acquire [%d, 0x%x]failed\n",
375 hwfn_index, trace->cmd);
386 return (ENXIO);
387 }
388
389 switch (trace->cmd) {
390
391 case QLNX_MCP_TRACE:
392 rval = ecore_dbg_mcp_trace_dump(p_hwfn, p_ptt,
393 buffer, (trace->size[hwfn_index] >> 2),

--- 21 unchanged lines hidden (view full) ---

415 case QLNX_FW_ASSERTS:
416 rval = ecore_dbg_fw_asserts_dump(p_hwfn, p_ptt,
417 buffer, (trace->size[hwfn_index] >> 2),
418 &num_dwords);
419 break;
420 }
421
422 if (rval != DBG_STATUS_OK) {
376 return (ENXIO);
377 }
378
379 switch (trace->cmd) {
380
381 case QLNX_MCP_TRACE:
382 rval = ecore_dbg_mcp_trace_dump(p_hwfn, p_ptt,
383 buffer, (trace->size[hwfn_index] >> 2),

--- 21 unchanged lines hidden (view full) ---

405 case QLNX_FW_ASSERTS:
406 rval = ecore_dbg_fw_asserts_dump(p_hwfn, p_ptt,
407 buffer, (trace->size[hwfn_index] >> 2),
408 &num_dwords);
409 break;
410 }
411
412 if (rval != DBG_STATUS_OK) {
423 QL_DPRINT1(ha, (ha->pci_dev, "%s : cmd = 0x%x failed [0x%x]\n",
424 __func__, trace->cmd, rval));
413 QL_DPRINT1(ha,"cmd = 0x%x failed [0x%x]\n", trace->cmd, rval);
425 num_dwords = 0;
426 }
427
428 ecore_ptt_release(p_hwfn, p_ptt);
429
430 trace->dwords[hwfn_index] = num_dwords;
431
432 if (num_dwords) {

--- 171 unchanged lines hidden (view full) ---

604
605 if ((nvram->data == NULL) || (nvram->data_len == 0))
606 return (EINVAL);
607
608 buf = qlnx_zalloc(nvram->data_len);
609
610 ret = copyin(nvram->data, buf, nvram->data_len);
611
414 num_dwords = 0;
415 }
416
417 ecore_ptt_release(p_hwfn, p_ptt);
418
419 trace->dwords[hwfn_index] = num_dwords;
420
421 if (num_dwords) {

--- 171 unchanged lines hidden (view full) ---

593
594 if ((nvram->data == NULL) || (nvram->data_len == 0))
595 return (EINVAL);
596
597 buf = qlnx_zalloc(nvram->data_len);
598
599 ret = copyin(nvram->data, buf, nvram->data_len);
600
612 QL_DPRINT9(ha,
613 (ha->pci_dev, "%s: issue cmd = 0x%x data = %p "
614 " data_len = 0x%x ret = 0x%x exit\n", __func__,
615 cmd, nvram->data, nvram->data_len, ret));
601 QL_DPRINT9(ha, "issue cmd = 0x%x data = %p \
602 data_len = 0x%x ret = 0x%x exit\n",
603 cmd, nvram->data, nvram->data_len, ret);
616
617 if (ret == 0) {
618 ret = ecore_mcp_nvm_write(&ha->cdev, cmd,
619 nvram->offset, buf, nvram->data_len);
620 }
621
604
605 if (ret == 0) {
606 ret = ecore_mcp_nvm_write(&ha->cdev, cmd,
607 nvram->offset, buf, nvram->data_len);
608 }
609
622 QL_DPRINT9(ha,
623 (ha->pci_dev, "%s: cmd = 0x%x data = %p "
624 " data_len = 0x%x resp = 0x%x ret = 0x%x exit\n",
625 __func__, cmd, nvram->data, nvram->data_len,
626 ha->cdev.mcp_nvm_resp, ret));
610 QL_DPRINT9(ha, "cmd = 0x%x data = %p \
611 data_len = 0x%x resp = 0x%x ret = 0x%x exit\n",
612 cmd, nvram->data, nvram->data_len, ha->cdev.mcp_nvm_resp, ret);
627
628 free(buf, M_QLNXBUF);
629
630 return (ret);
631}
632
633static int
634qlnx_read_nvram(qlnx_host_t *ha, qlnx_nvram_t *nvram)

--- 4 unchanged lines hidden (view full) ---

639 if ((nvram->data == NULL) || (nvram->data_len == 0))
640 return (EINVAL);
641
642 buf = qlnx_zalloc(nvram->data_len);
643
644 ret = ecore_mcp_nvm_read(&ha->cdev, nvram->offset, buf,
645 nvram->data_len);
646
613
614 free(buf, M_QLNXBUF);
615
616 return (ret);
617}
618
619static int
620qlnx_read_nvram(qlnx_host_t *ha, qlnx_nvram_t *nvram)

--- 4 unchanged lines hidden (view full) ---

625 if ((nvram->data == NULL) || (nvram->data_len == 0))
626 return (EINVAL);
627
628 buf = qlnx_zalloc(nvram->data_len);
629
630 ret = ecore_mcp_nvm_read(&ha->cdev, nvram->offset, buf,
631 nvram->data_len);
632
647 QL_DPRINT9(ha, (ha->pci_dev, "%s: data = %p data_len = 0x%x "
648 " resp = 0x%x ret = 0x%x exit\n", __func__,
649 nvram->data, nvram->data_len,
650 ha->cdev.mcp_nvm_resp, ret));
633 QL_DPRINT9(ha, " data = %p data_len = 0x%x \
634 resp = 0x%x ret = 0x%x exit\n",
635 nvram->data, nvram->data_len, ha->cdev.mcp_nvm_resp, ret);
651
652 if (ret == 0) {
653 ret = copyout(buf, nvram->data, nvram->data_len);
654 }
655
656 free(buf, M_QLNXBUF);
657
658 return (ret);

--- 8 unchanged lines hidden (view full) ---

667 if ((nvram->data == NULL) || (nvram->data_len == 0))
668 return (EINVAL);
669
670 buf = qlnx_zalloc(nvram->data_len);
671
672
673 ret = ecore_mcp_nvm_resp(&ha->cdev, buf);
674
636
637 if (ret == 0) {
638 ret = copyout(buf, nvram->data, nvram->data_len);
639 }
640
641 free(buf, M_QLNXBUF);
642
643 return (ret);

--- 8 unchanged lines hidden (view full) ---

652 if ((nvram->data == NULL) || (nvram->data_len == 0))
653 return (EINVAL);
654
655 buf = qlnx_zalloc(nvram->data_len);
656
657
658 ret = ecore_mcp_nvm_resp(&ha->cdev, buf);
659
675 QL_DPRINT9(ha, (ha->pci_dev, "%s: data = %p data_len = 0x%x "
676 " resp = 0x%x ret = 0x%x exit\n", __func__,
677 nvram->data, nvram->data_len,
678 ha->cdev.mcp_nvm_resp, ret));
660 QL_DPRINT9(ha, "data = %p data_len = 0x%x \
661 resp = 0x%x ret = 0x%x exit\n",
662 nvram->data, nvram->data_len, ha->cdev.mcp_nvm_resp, ret);
679
680 if (ret == 0) {
681 ret = copyout(buf, nvram->data, nvram->data_len);
682 }
683
684 free(buf, M_QLNXBUF);
685
686 return (ret);

--- 16 unchanged lines hidden (view full) ---

703
704 case QLNX_NVRAM_CMD_READ_NVRAM:
705 ret = qlnx_read_nvram(ha, nvram);
706 break;
707
708 case QLNX_NVRAM_CMD_SET_SECURE_MODE:
709 ret = ecore_mcp_nvm_set_secure_mode(&ha->cdev, nvram->offset);
710
663
664 if (ret == 0) {
665 ret = copyout(buf, nvram->data, nvram->data_len);
666 }
667
668 free(buf, M_QLNXBUF);
669
670 return (ret);

--- 16 unchanged lines hidden (view full) ---

687
688 case QLNX_NVRAM_CMD_READ_NVRAM:
689 ret = qlnx_read_nvram(ha, nvram);
690 break;
691
692 case QLNX_NVRAM_CMD_SET_SECURE_MODE:
693 ret = ecore_mcp_nvm_set_secure_mode(&ha->cdev, nvram->offset);
694
711 QL_DPRINT9(ha, (ha->pci_dev,
712 "%s: QLNX_NVRAM_CMD_SET_SECURE_MODE "
713 " resp = 0x%x ret = 0x%x exit\n", __func__,
714 ha->cdev.mcp_nvm_resp, ret));
695 QL_DPRINT9(ha, "QLNX_NVRAM_CMD_SET_SECURE_MODE \
696 resp = 0x%x ret = 0x%x exit\n",
697 ha->cdev.mcp_nvm_resp, ret);
715 break;
716
717 case QLNX_NVRAM_CMD_DEL_FILE:
718 ret = ecore_mcp_nvm_del_file(&ha->cdev, nvram->offset);
719
698 break;
699
700 case QLNX_NVRAM_CMD_DEL_FILE:
701 ret = ecore_mcp_nvm_del_file(&ha->cdev, nvram->offset);
702
720 QL_DPRINT9(ha, (ha->pci_dev,
721 "%s: QLNX_NVRAM_CMD_DEL_FILE "
722 " resp = 0x%x ret = 0x%x exit\n", __func__,
723 ha->cdev.mcp_nvm_resp, ret));
703 QL_DPRINT9(ha, "QLNX_NVRAM_CMD_DEL_FILE \
704 resp = 0x%x ret = 0x%x exit\n",
705 ha->cdev.mcp_nvm_resp, ret);
724 break;
725
726 case QLNX_NVRAM_CMD_PUT_FILE_BEGIN:
727 ret = ecore_mcp_nvm_put_file_begin(&ha->cdev, nvram->offset);
728
706 break;
707
708 case QLNX_NVRAM_CMD_PUT_FILE_BEGIN:
709 ret = ecore_mcp_nvm_put_file_begin(&ha->cdev, nvram->offset);
710
729 QL_DPRINT9(ha, (ha->pci_dev,
730 "%s: QLNX_NVRAM_CMD_PUT_FILE_BEGIN "
731 " resp = 0x%x ret = 0x%x exit\n", __func__,
732 ha->cdev.mcp_nvm_resp, ret));
711 QL_DPRINT9(ha, "QLNX_NVRAM_CMD_PUT_FILE_BEGIN \
712 resp = 0x%x ret = 0x%x exit\n",
713 ha->cdev.mcp_nvm_resp, ret);
733 break;
734
735 case QLNX_NVRAM_CMD_GET_NVRAM_RESP:
736 ret = qlnx_get_nvram_resp(ha, nvram);
737 break;
738
739 default:
740 ret = EINVAL;

--- 142 unchanged lines hidden ---
714 break;
715
716 case QLNX_NVRAM_CMD_GET_NVRAM_RESP:
717 ret = qlnx_get_nvram_resp(ha, nvram);
718 break;
719
720 default:
721 ret = EINVAL;

--- 142 unchanged lines hidden ---