Emulex Logo
OneCoreā„¢ Storage SDK Release 11.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
elxu_dump.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2018, Emulex
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 are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors
16  * may be used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  *
31  */
32 
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <unistd.h>
36 #include <stdarg.h>
37 #include <getopt.h>
38 #include <stdint.h>
39 #include <string.h>
40 #include <ctype.h>
41 #include <fcntl.h>
42 #include <sys/stat.h>
43 #include <errno.h>
44 #include <sys/ioctl.h>
45 #include <sys/utsname.h>
46 
47 #include <elxu_device.h>
48 #include <elxu_sli4.h>
49 #include <elxu_sky.h>
50 #include <elxu_lancer.h>
51 #include <elxu_dump.h>
52 #include <ocs_ioctl.h>
53 #include <ecd_api.h>
54 #include <elxu_common.h>
55 #include <elxu_mgmt.h>
56 #include <elx_pt_ioctl.h>
57 
58 
59 /**
60  * @brief test write permissions for given file
61  *
62  * @param filename File for which write test is performed
63  *
64  */
65 static int elxu_test_file_write(const char *filename) {
66  FILE *out;
67  out = fopen(filename, "wb");
68  if (out == NULL) {
69  printf("Error: can't create file: %s\n", filename);
70  return -1;
71  } else
72  fclose(out);
73  return 0;
74 }
75 
76 /**
77  * @brief FAT data upload functionality
78  *
79  *
80  * @param device_p The pointer to the HBA descriptor structure.
81  * @param fname_p The pointer to the file name string.
82  */
83 static int fat_upload (elxu_device_t *device_p, char const *fname_p)
84 {
85 
86  int fd;
87  uint8_t *buf_p;
88  int retval = 0;
89  int fatLength;
90 
91  /*
92  * Validate arguments
93  */
94  if (device_p == NULL)
95  {
96  printf("Null pointer\n");
97  return -1;
98  }
99 
100  if (fname_p == NULL)
101  {
102  fname_p = DEFAULT_OUTPUT_FILE_NAME;
103  }
104 
105  /* test to make sure we can write to outfile before continuing */
106  if (elxu_test_file_write(fname_p)) {
107  printf ("Failed to open file for writing, file: %s\n", fname_p);
108  return -1;
109  }
110 
111  // Fetch the length of the FAT
112  if ((fatLength = fat_info(device_p)) < 0)
113  {
114  printf ("Fetch FAT info failure \n");
115  return -1;
116  }
117 
118  if (fatLength == 0)
119  {
120  printf ("FAT fetch - nothing to retrieve\n");
121  return 0;
122  }
123 
124  printf ("Fat length is %d bytes\n", fatLength);
125  /*
126  * Allocate space to retrieve the file headers.
127  */
128  if ((buf_p = zmalloc(fatLength)) == NULL)
129  {
130  printf("Malloc failure - (%s)\n", strerror(errno));
131  return MALLOC_FAILED;
132  }
133 
134  // Read FAT
135  if ((retval = fat_read(device_p, buf_p, fatLength)) < 0)
136  {
137  printf ("FAT read Failed with error code: %d\n", retval);
138  }
139  else
140  {
141  /*
142  * Open file
143  */
144  if ((fd = open(fname_p, O_CREAT | O_WRONLY, 0644)) < 0)
145  {
146  zfree(buf_p);
147  return -1;
148  }
149 
150  if (write(fd, buf_p, fatLength) < 0)
151  {
152  printf("write file failure, (%s)\n", strerror(errno));
153  retval = -1;
154  }
155  close(fd);
156  }
157 
158  zfree(buf_p);
159  return retval;
160 }
161 
162 
163 void elxu_driver_dump(elxu_device_t *device, int bufsize, ocs_ioctl_ddump_arg_t *args)
164 {
165 
166  char *buf;
167  ocs_ioctl_ddump_t req;
168  int rval;
169 
170  if (bufsize <= 0) {
171  fprintf(stderr, "Invalid bufsize: %d\n", bufsize);
172  return;
173  }
174 
175  buf = malloc(bufsize+1);
176  if (buf == NULL) {
177  fprintf(stderr, "Unable to allocate buffer of %d KBytes\n", bufsize/1024);
178  return;
179  }
180 
181  memset(&req, 0, sizeof(req));
182  req.args = *args;
183  req.user_buffer = (uint8_t *)buf;
184  req.user_buffer_len = bufsize;
185 
186  rval = elxu_ioctl_device(device, OCS_IOCTL_CMD_GET_DDUMP, &req);
187 
188  if (rval < 0) {
189  perror("ioctl");
190  } else {
191  switch (args->action) {
192  case OCS_IOCTL_DDUMP_GET:
194  if (req.bytes_written) {
195  buf[req.bytes_written] = '\0';
196  printf("%s\n", buf);
197  } else {
198  printf("No driver-dump data returned\n");
199  }
200  break;
202  break;
203  }
204  }
205 
206  free(buf);
207 }
208 
209 /**
210  * @brief FAT data upload functionality
211  *
212  *
213  * @param device_p The pointer to the HBA descriptor structure.
214  * @param fname_p The pointer to the file name string.
215  */
216 int ext_fat_read_string_table_upld (elxu_device_t *device_p, char const *fname_p)
217 {
218  uint32_t tbl_info_len;
220  uint32_t remaining_bytes = 0;
221  uint32_t read_bytes = 0;
222  uint32_t tbl_data_block_size = 2*1024;
223  int fd;
224  int fd1;
225  const char *filename = "efdstr.data";
226 
227  tbl_info_len = sizeof (mbox_ext_fat_read_string_params_t) + tbl_data_block_size;
228 
229  if ((tblinfo = malloc (tbl_info_len)) == NULL)
230  {
231  printf("Malloc failure - (%s)\n", strerror(errno));
232  return MALLOC_FAILED;
233  }
234 
235  if (fname_p == NULL)
236  {
237  fname_p = filename;
238  }
239 
240  printf ("Filename :%s \n", fname_p);
241  /*
242  * Open file
243  */
244  if ((fd = open(fname_p, O_CREAT | O_WRONLY, 0644)) < 0)
245  {
246  printf("open file failure, (%s)\n", strerror(errno));
247  zfree(tblinfo);
248  return -1;
249  }
250 
251  /*
252  * Open file
253  */
254  if ((fd1 = open("strTbl", O_CREAT | O_WRONLY, 0644)) < 0)
255  {
256  printf("open file failure, (%s)\n", strerror(errno));
257  goto error_Cleanup;
258  }
259 
260  do
261  {
262  memset (tblinfo, 0, tbl_info_len);
263 
264  if (ext_fat_read_string_table (device_p, tblinfo, tbl_info_len, tbl_data_block_size, read_bytes) < 0)
265  {
266  printf ("Reading string table failed\n");
267  goto error_Cleanup_fd1;
268  }
269 
270  if (write(fd, tblinfo->table_data, tblinfo->num_returned_bytes) < 0)
271  {
272  printf("write file failure, (%s)\n", strerror(errno));
273  goto error_Cleanup_fd1;
274  }
275 
276  if (write(fd1, tblinfo->table_data, tblinfo->num_returned_bytes) < 0)
277  {
278  printf("write file failure, (%s)\n", strerror(errno));
279  goto error_Cleanup_fd1;
280  }
281  read_bytes+= tblinfo->num_returned_bytes;
282  remaining_bytes = tblinfo->num_remaining_bytes;
283 
284  } while (remaining_bytes);
285 
286  printf ("String table was read successfully : %d Bytes \n", read_bytes);
287 
288  zfree(tblinfo);
289  close (fd);
290  close (fd1);
291  return 0;
292 
293 error_Cleanup_fd1:
294  close(fd1);
295 
296 error_Cleanup:
297  close(fd);
298  zfree(tblinfo);
299  return -1;
300 }
301 
302 
303 /**
304  * @brief Displays EXT FAT capabilities
305  *
306  * @param device_p The pointer to the HBA descriptor structure.
307  */
308 
310 {
311  uint32_t bufferLength = 3*1024+256;
312  ext_fat_config_params_t *config;
313  int rval, i, j;
314 
315  if ((config = zmalloc(bufferLength)) == NULL)
316  {
317  printf("Malloc failure - (%s)\n", strerror(errno));
318  return MALLOC_FAILED;
319  }
320 
321  rval = get_ext_fat_capabilities(device_p, EXT_FAT_PARAM_TYPE_DEFAULT, config, bufferLength);
322 
323  if (rval)
324  {
325  printf ("Error: rval %d\n", rval);
326  zfree(config);
327  return -1;
328  }
329  else
330  {
331  ext_fat_module_t *module;
332  ext_fat_mode_t *mode;
333 
334  printf("max_log_entries %d\n", config->max_log_entries);
335  printf("log_entry_size %d\n", config->log_entry_size);
336  printf("logging_type %d\n", config->logging_type);
337  printf("max_logging_functions %d\n", config->max_logging_functions);
338  printf("max logging port %d\n", config->max_logging_ports);
339  printf("supported_modes %s%s%s%s\n",
340  config->supported_modes & LOG_MODE_UART_MASK ? "uart " : "",
341  config->supported_modes & LOG_MODE_RAM_MASK ? "ram " : "",
342  config->supported_modes & LOG_MODE_NVRAM_MASK ? "nvram " : "",
343  config->supported_modes & LOG_MODE_NWTK_MASK ? "nwtk " : "");
344 
345  printf("num_modules %d\n", config->num_modules);
346 
347  module = config->debug_module;
348 
349  for (i = 0; i < config->num_modules; i ++)
350  {
351  printf("[%d]\t%-16s\tmodule_id %d\tnum_modes %d\n", i, module->module_str,
352  module->module_id, module->num_modes);
353  mode = module->mode_trace_level;
354  if (module->num_modes > 16)
355  {
356  printf("Error: suspected invalid num_modes - terminating dump\n");
357  break;
358  }
359  for (j = 0; j < module->num_modes; j ++, mode ++)
360  {
361  printf (" [%d] mode %d port_mask %04X trace_level %08X function_mask %016llX\n",
362  j, mode->mode, mode->port_mask, mode->trace_level, (long long unsigned int) mode->function_mask);
363  }
364  module = (ext_fat_module_t*)mode;
365  }
366  }
367  zfree(config);
368  return 0;
369 }
370 
371 
372 
373 
374 /**
375  * @brief EXT FAT data upload functionality
376  *
377  *
378  * @param device_p The pointer to the HBA descriptor structure.
379  * @param fname_p The pointer to the file name string.
380  */
381 
382 static int ext_fat_snapshot_upload (elxu_device_t *device_p, char const *fname_p)
383 {
384  int len;
385 
386  uint8_t *buf_p;
387 
388  if ((len = ext_fat_config_snapshot(device_p)) < 0)
389  {
390  printf ("Error executing EFD config snapshot mailbox cmd.\n");
391  }
392  else
393  {
394  printf ("EFD Snapshot size is %d logs\n", len);
395 
396  if ((buf_p = (uint8_t *) malloc (len*sizeof(arm_trace_record_t))) == NULL)
397  {
398  printf("Malloc failure - (%s)\n", strerror(errno));
399  return -1;
400  }
401 
402  printf ("Retrieve EFD snapshot \n");
403  if (ext_fat_retrieve_snapshot (device_p, buf_p, len*sizeof(arm_trace_record_t), len) < 0)
404  {
405  printf ("Retrieve failed\n");
406  }
407  else
408  {
409  int fd;
410  const char *filename = "efd.data";
411 
412  if (fname_p == NULL)
413  {
414  fname_p = filename;
415  }
416  /*
417  * Open file
418  */
419  if ((fd = open(fname_p, O_WRONLY| O_APPEND |O_CREAT, 0644)) < 0)
420  {
421  printf("open file failure, (%s)\n", strerror(errno));
422  zfree(buf_p);
423  return -1;
424  }
425 
426  if (write(fd, buf_p, (len*sizeof(arm_trace_record_t))) < 0) \
427  {
428  printf("write file failure, (%s)\n", strerror(errno));
429  }
430  printf ("EFD snapshot was retrieved successfully \n");
431  close(fd);
432  }
433  zfree (buf_p);
434  }
435 
436  return 0;
437 }
438 
439 
440 /**
441  * @brief EXT FAT data upload functionality
442  *
443  *
444  * @param device_p The pointer to the HBA descriptor structure.
445  * @param fname_p The pointer to the file name string.
446  */
447 
448 static int ext_fat_generate_efd_file (elxu_device_t *device_p, char const *fname_p)
449 {
450  const char *filename = "data.efd";
451 
452  if (fname_p == NULL)
453  {
454  printf ("Using generic file name - %s\n", filename);
455  fname_p = filename;
456  }
457 
458  /* test to make sure we can write to outfile before continuing */
459  if (elxu_test_file_write(fname_p)) {
460  printf ("Failed to open file for writing, file: %s\n", fname_p);
461  return -1;
462  }
463 
464  if (ext_fat_read_string_table_upld (device_p,fname_p) < 0)
465  {
466  printf ("EFD String table retrieval failed \n");
467  return (-1);
468  }
469 
470  if (ext_fat_snapshot_upload (device_p, fname_p) < 0)
471  {
472  printf ("EFD Snapshot retrieval failed \n");
473  return -1;
474  }
475  return 0;
476 }
477 
478 
479 
480 /**
481  * @brief Lancer dump data upload functionality
482  *
483  *
484  * @param device_p The pointer to the HBA descriptor structure.
485  * @param fname_p The pointer to the file name string.
486  */
487 
488 static int lancer_hba_dump_upload(elxu_device_t *device_p, char const *fname_p)
489 {
490  const char *ofname = "dump.bin";
491  const char *objectName = "/dbg/dump.bin";
492  int rval = -1;
493  FILE *out;
494 
495  if (fname_p != NULL)
496  {
497  ofname = fname_p;
498  }
499 
500  /* test to make sure we can write to outfile before continuing */
501  if (elxu_test_file_write(ofname)) {
502  printf ("Failed to open file for writing, file: %s\n", ofname);
503  return -1;
504  }
505 
506  rval = sli4_object_length(device_p, objectName);
507 
508  if (rval < 0)
509  {
510  printf("Error: sli4_object_length(%s) returned %d\n", objectName, rval);
511  return -1;
512  }
513 
514  uint32_t objectLength = rval;
515  printf ("Length of object %s is %d\n", objectName, objectLength);
516  if (objectLength == 0) {
517  printf("Length of object %s is zero, nothing to read\n", objectName);
518  return 0;
519  }
520 
521  void *buffer = malloc(objectLength);
522  if (!buffer)
523  {
524  printf("Malloc failure - (%s)\n", strerror(errno));
525  return MALLOC_FAILED;
526  }
527 
528  rval = sli4_object_read(device_p, objectName, buffer, objectLength);
529  if (rval < 0)
530  {
531  printf("Error: sli4_object_read(%s) failed: %d\n", objectName, rval);
532  return -1;
533  }
534 
535  out = fopen(ofname, "wb");
536  if (out) {
537  size_t written = 0;
538  written = fwrite(buffer, objectLength, 1, out);
539  fclose(out);
540  printf ("File %s created\n", ofname);
541 
542  if (written) {
543  // only delete file if write was successful
544  if (sli4_object_delete (device_p, objectName) < 0) {
545  printf ("Failed to delete object %s from SLI device\n", objectName);
546  rval = -1;
547  } else {
548  printf ("Object %s was deleted from SLI device\n", objectName);
549  rval = 0;
550  }
551  } else {
552  printf("Failed to write to file: %s\n", ofname);
553  rval = -1;
554  }
555  } else {
556  printf("Failed to write to file: %s\n", ofname);
557  rval = -1;
558  }
559 
560  zfree (buffer);
561  return (rval);
562 }
563 
564 int hba_data_object_upload (elxu_device_t *device_p, char const *objname_p, char const *fname_p)
565 {
566  const char *ofname = "object.bin";
567  const char *objectName = objname_p;
568  int rval = -1;
569  FILE *out;
570 
571  if (fname_p != NULL)
572  {
573  ofname = fname_p;
574  }
575 
576  /* test to make sure we can write to outfile before continuing */
577  if (elxu_test_file_write(ofname)) {
578  printf ("Failed to open file for writing, file: %s\n", ofname);
579  return -1;
580  }
581 
582  printf ("object name : %s \n", objname_p);
583  rval = sli4_object_length(device_p, objectName);
584 
585  if (rval < 0)
586  {
587  printf("Error: sli4_object_length(%s) returned %d\n", objectName, rval);
588  return -1;
589  }
590 
591  uint32_t objectLength = rval;
592  printf ("Length of object is %d\n", objectLength);
593 
594  void *buffer = malloc(objectLength);
595  if (!buffer)
596  {
597  printf("Malloc failure - (%s)\n", strerror(errno));
598  return MALLOC_FAILED;
599  }
600 
601  rval = sli4_object_read(device_p, objectName, buffer, objectLength);
602  if (rval < 0)
603  {
604  printf("Error: sli4_object_read(%s) failed: %d\n", objectName, rval);
605  zfree (buffer);
606  return -1;
607  }
608  printf("rval %d\n", rval);
609 
610 
611  out = fopen(ofname, "wb");
612  if (out)
613  {
614  fwrite(buffer, objectLength, 1, out);
615  fclose(out);
616  printf ("File %s created\n", ofname);
617  }
618 
619  zfree (buffer);
620  return (rval);
621 }
622 
623 /**
624  * @brief Trigger dump generation on Lancer
625  *
626  * The functionality to generate a dump on Lancer.
627  *
628  * @param device_p The pointer to the HBA descriptor structure.
629  */
630 int lancer_gen_dump(elxu_device_t *device_p, int fdb_dump)
631 {
632  int rc;
633 
634  printf("Generating dump..\n");
635  if (fdb_dump) {
636  rc = elxu_device_exec(device_p, "/ocs/driver/fdb_gendump", NULL, 0, NULL, 0);
637  }
638  else {
639  rc = elxu_device_exec(device_p, "/ocs/driver/gendump", NULL, 0, NULL, 0);
640  }
641 
642  if (rc == 0) {
643  printf("Dump successfully generated and can now be read from SLI device\n");
644  } else {
645  printf("Dump generation failed.\n");
646  }
647 
648  return rc;
649 }
650 
651 /**
652  * @brief Trigger dump-to-host on Lancer
653  *
654  * This function uses Lancer's dump-to-host capability to cause
655  * a dump to be generated and to transfer that dump into host
656  * memory. The transfered dump is stored in a file.
657  *
658  * @param device_p The pointer to the HBA descriptor structure.
659  */
660 int lancer_dump_to_host(elxu_device_t *device_p, const char *fname, int fdb_dump)
661 {
662  int rc;
663  uint8_t *dump_buffer;
664  const char *ofname = "dump.bin";
665  FILE *out;
666  uint32_t actual_size;
667  uint8_t *response_bytes;
668  uint32_t max_dump_size = 0;
669 
670  if (fname != NULL)
671  {
672  ofname = fname;
673  }
674 
675  /* test to make sure we can write to outfile before continuing */
676  if (elxu_test_file_write(ofname)) {
677  printf ("Failed to open file for writing, file: %s\n", ofname);
678  return -1;
679  }
680 
681  max_dump_size = strtoul(elxu_device_get_value(device_p, "/ocs/fw_dump_max_size"), NULL, 0);
682  if (!max_dump_size) {
683  printf("Unable to determine the size of dump \n");
684  return -1;
685  }
686 
687  dump_buffer = malloc(max_dump_size);
688  if (dump_buffer == NULL) {
689  perror("malloc");
690  return -1;
691  }
692 
693  printf("Starting dump...\n");
694 
695  if (fdb_dump) {
696  rc = elxu_device_exec(device_p, "/ocs/driver/fdb_dump_to_host", NULL, 0, dump_buffer, max_dump_size);
697  } else {
698  rc = elxu_device_exec(device_p, "/ocs/driver/dump_to_host", NULL, 0, dump_buffer, max_dump_size);
699  }
700 
701  if (rc != 0) {
702  perror("ioctl");
703  printf("Dump generation failed.\n");
704  free(dump_buffer);
705  return -1;
706  }
707 
708  /* The first 32 bits of the dump contain the actual length but we
709  need to change the endianess */
710  response_bytes = dump_buffer;
711  actual_size = (response_bytes[0] << 24) |
712  (response_bytes[1] << 16) |
713  (response_bytes[2] << 8) |
714  (response_bytes[3]);
715 
716  if (actual_size > max_dump_size) {
717  printf("Reported dump size is higher than max allowed dump size (%d). Dump may have been truncated\n", max_dump_size);
718  actual_size = max_dump_size;
719  }
720 
721  out = fopen(ofname, "wb");
722  if (out)
723  {
724  size_t written = 0;
725  written = fwrite(dump_buffer, actual_size, 1, out);
726  fclose(out);
727  printf ("File %s created\n", ofname);
728  if (dump_buffer == NULL)
729  printf("Dump buffer is NULL\n");
730 
731  if (!written) {
732  printf("Failed to write to file: %s\n", ofname);
733  } else {
734  printf("Dump written to file %s\n", ofname);
735  }
736  }
737 
738  zfree (dump_buffer);
739 
740  return rc;
741 }
742 
743 static size_t ocs_write_buffer_to_file(const char *ofname, void *src_buffer, size_t byte_count)
744 {
745  FILE *fp;
746  size_t written = 0;
747 
748  fp = fopen(ofname, "wb");
749  if (fp)
750  {
751  written = fwrite(src_buffer, byte_count, 1, fp);
752  fclose(fp);
753  }
754  return written;
755 }
756 
757 /**
758  * @brief gather firmware diagnostic logs
759  *
760  * The functionality to extract firmware diagnostic logs to a file
761  *
762  * @param device_p Pointer to HBA descriptor structure.
763  * @param fname Output file name.
764  */
765 int elxu_get_fw_diagnostic_log(elxu_device_t *device_p, char const *fname)
766 {
767 #define OCS_FW_DIAG_LOG_SIZE_MAX (1*1024*1024) // 1MB
768 #define MAX_FW_LOG_BUFFER_SIZE (16*1024*1024) // 16MB
769  uint8_t *diag_log_buffer;
770  size_t buffer_size;
771  uint32_t bytes_copied = 0;
772  int rc = 0;
773 
774  /* Account for 32-bit header to get notified of the exact number of bytes
775  * copied by driver to application buffer.
776  */
777  buffer_size = MAX_FW_LOG_BUFFER_SIZE + sizeof(uint32_t);
778 
779  /* test to make sure we can write to outfile before continuing */
780  if (elxu_test_file_write(fname)) {
781  printf ("Failed to open file, %s for writing\n", fname);
782  return -1;
783  }
784 
785  diag_log_buffer = malloc(buffer_size);
786  if (diag_log_buffer == NULL) {
787  perror("malloc : fw diagnostic log buffer");
788  return -1;
789  }
790 
791  rc = elxu_device_exec(device_p, "/ocs/driver/fw_diag_log", NULL, 0, diag_log_buffer, buffer_size);
792  if (rc < 0) {
793  printf("FW diagnostic logs copy failed, rc %d.\n", rc);
794  goto release_buffer;
795  }
796 
797  bytes_copied = *((uint32_t *)diag_log_buffer);
798  if (bytes_copied) {
799  /* Copy only driver signals it copied non-zero bytes of data from
800  * fw registered buffer to application buffer.
801  */
802  ocs_write_buffer_to_file(fname, diag_log_buffer + sizeof(uint32_t), bytes_copied);
803  printf("Wrote %d bytes of firmware diagnostic log to %s\n", bytes_copied, fname);
804  }
805 
806 release_buffer:
807  zfree(diag_log_buffer);
808  return rc;
809 }
810 
811 
812 /**
813  * @brief FAT data upload functionality
814  *
815  * The functionality which is handling the request to retrieve the FAT data
816  * from Skyhawk.
817  *
818  * @param device_p The pointer to the HBA descriptor structure.
819  * @param fname_p The pointer to the file name string.
820  * @param req The request data type.
821  */
822 int hba_data_upload(elxu_device_t *device_p, char const *fname_p, data_type_req_t req)
823 {
824 
825  int retval = -1;
826  if (is_lancer(device_p) || is_prism(device_p)) {
827  return (lancer_hba_dump_upload (device_p, fname_p));
828  } else if (is_skyhawk(device_p)) {
829  if (req == FAT_DATA)
830  {
831  retval = fat_upload(device_p, fname_p);
832  }
833  if (req == EFD_DATA)
834  {
835  retval = ext_fat_generate_efd_file (device_p, fname_p);
836  }
837  return retval;
838  } else {
839  printf ("Unknown HBA \n");
840  return -1;
841  }
842  return 0;
843 
844 }
845 
846 /**
847  * @brief Core Dump functionality
848  *
849  * Handle the request to retrieve the core dump from Skyhawk.
850  *
851  * @param device_p The pointer to the HBA descriptor structure.
852  * @param fname_p file name of file to to which dump is written
853  *
854  */
856  elxu_device_t *device_p,
857  char *fname_p,
858  int test_dump)
859 {
860  int rc;
861  uint8_t *buffer;
862  uint32_t bufferLength = ECD_MIN_BUFFER_SIZE;
863  char *sky_template_ecdargs[] = {"dead", "skytemplate"};
864  char *test_template_ecdargs[] = {"dead", "testtemplate"};
865  char **ecdargs;
866  uint32_t ecdargs_count = ARRAY_SIZE(sky_template_ecdargs);
867  struct utsname utsname;
868  ecd_fwState_t fwState = ECD_FW_STATE_UE;
869  ecd_get_params_t params;
870  int major;
871  int minor;
872  int release;
873 
874  if (fname_p == NULL) {
875  fname_p = "dump.core";
876  }
877 
878  /* test to make sure we can write to outfile before continuing */
879  if (elxu_test_file_write(fname_p)) {
880  printf ("Failed to open file for writing, file: %s\n", fname_p);
881  return -1;
882  }
883 
884  /* Build parameters */
885  memset(&params, 0, sizeof(params));
886  params.instance = device_p->deviceIndex;
887 
888  if (test_dump) {
889  ecdargs = test_template_ecdargs;
890  ecdargs_count = ARRAY_SIZE(test_template_ecdargs);
891  } else if (is_skyhawk(device_p)) {
892  ecdargs = sky_template_ecdargs;
893  ecdargs_count = ARRAY_SIZE(sky_template_ecdargs);
894  } else {
895  return -1;
896  }
897 
898  /* Using uname() system call fetch required parameter information */
899  rc = uname(&utsname);
900 
901  if (rc != 0) {
902  strncpy(params.system_name, "unknown", sizeof(params.system_name));
903  strncpy(params.os_name, "unknown", sizeof(params.os_name));
904  } else {
905  strncpy(params.os_name, utsname.release, sizeof(params.os_name));
906  strncpy(params.system_name, utsname.nodename, sizeof(params.system_name));
907  }
908  params.ioctl_high_version = 1;
909  params.ioctl_low_version = 0;
910 
911  /* Parse out the linux version, pass in 2.6.32 as 26.32 */
912  sscanf(utsname.release, "%d.%d.%d", &major, &minor, &release);
913  params.os_major = major*10 + minor;
914  params.os_minor = release;
915 
916  /* set SLI_INTF from device structure */
917  params.sli_intf = elxu_get_sliintf(device_p);
918  params.asic_id = elxu_get_asic_id(device_p);
919 
920  buffer = malloc(bufferLength);
921  if (buffer == NULL)
922  {
923  printf("Error: coredump malloc (%d) failed\n", bufferLength);
924  return -1;
925  }
926  rc = ecd_GetCoreDumpData(device_p, fwState, &params, buffer, bufferLength,
927  ecdargs_count, ecdargs);
928 
929  printf("ecd_GetCoreDumpData returned %d\n", rc);
930 
931  /* A return value >= 0 means that there is data in the buffer */
932 
933  if ((rc > 0) && (fname_p != NULL)) {
934  FILE *out;
935  uint32_t len = rc;
936 
937  out = fopen(fname_p, "wb");
938  if (out == NULL)
939  printf("Error: can't create %s\n", fname_p);
940  else {
941  rc = fwrite(buffer, 1, len, out);
942  if (rc != len)
943  printf("Error: fwrite failed: %d\n", rc);
944  fclose(out);
945  }
946  }
947 
948  free(buffer);
949  return 0;
950 }
951 
952 /****************************************************************************************************
953  * Helper functions for Core Dump
954  *
955  * These helper functions implement an interface to the Emulex OCS driver using the ioctl() interface.
956  *
957  * The customer implementation would replace these with functions that interface to their particular
958  * driver.
959  */
960 static int enable_helper_trace = 0;
961 
962 #define helper_trace(fmt, ...) \
963  do { \
964  if (enable_helper_trace) \
965  printf(fmt, ##__VA_ARGS__); \
966  } while(0)
967 
968 
969 void ecd_log(char *fmt, ...)
970 {
971  va_list ap;
972 
973  va_start(ap, fmt);
974  vprintf(fmt, ap);
975  va_end(ap);
976 }
977 
978 void os_assert(char *message, uint32_t Line, char *File)
979 {
980  ecd_log("%s(%d) %s\n", File, Line, message);
981  exit(0);
982 }
983 
984 void os_stall(void *ctx, uint32_t usecTime)
985 {
986  usleep(usecTime);
987 }
988 
989 void os_cfg_read8 (void *ctx, uint32_t offset, uint32_t *pdata)
990 {
991  int32_t rc;
992  elxu_device_t *device = (elxu_device_t *)ctx;
993 
994  if (device->driver == DEVICE_DRIVER_OCS) {
996 
997  helper_trace("%-16s: offset x%x\n", __func__, offset);
998 
999  memset(&cmd, 0, sizeof(cmd));
1001  cmd.offset = offset;
1002  rc = elxu_ioctl_device(device, OCS_IOCTL_CMD_ECD_HELPER, &cmd);
1003  if (rc == 0)
1004  *pdata = cmd.data;
1005  } else if (device->driver == DEVICE_DRIVER_PT) {
1006  elx_pt_ioctl_ecd_helper_t cmd;
1007 
1008  helper_trace("%-16s: offset x%x\n", __func__, offset);
1009 
1010  memset(&cmd, 0, sizeof(cmd));
1011  cmd.cmd = ELX_PT_ECD_HELPER_CFG_READ8;
1012  cmd.offset = offset;
1013  rc = elxu_ioctl_device(device, IOCTL_CMD_ELX_PT_ECD_HELPER, &cmd);
1014  if (rc == 0)
1015  *pdata = cmd.data;
1016  }
1017 }
1018 
1019 void os_cfg_read16(void *ctx, uint32_t offset, uint32_t *pdata)
1020 {
1021  int32_t rc;
1022  elxu_device_t *device = (elxu_device_t *)ctx;
1023 
1024  if (device->driver == DEVICE_DRIVER_OCS) {
1026 
1027  helper_trace("%-16s: offset x%x\n", __func__, offset);
1028 
1029  memset(&cmd, 0, sizeof(cmd));
1031  cmd.offset = offset;
1032 
1033  rc = elxu_ioctl_device(device, OCS_IOCTL_CMD_ECD_HELPER, &cmd);
1034  if (rc == 0)
1035  *pdata = cmd.data;
1036  } else if (device->driver == DEVICE_DRIVER_PT) {
1037  elx_pt_ioctl_ecd_helper_t cmd;
1038 
1039  helper_trace("%-16s: offset x%x\n", __func__, offset);
1040 
1041  memset(&cmd, 0, sizeof(cmd));
1042  cmd.cmd = ELX_PT_ECD_HELPER_CFG_READ16;
1043  cmd.offset = offset;
1044 
1045  rc = elxu_ioctl_device(device, IOCTL_CMD_ELX_PT_ECD_HELPER, &cmd);
1046  if (rc == 0)
1047  *pdata = cmd.data;
1048  }
1049 }
1050 void os_cfg_read32(void *ctx, uint32_t offset, uint32_t *pdata)
1051 {
1052  int32_t rc;
1053  elxu_device_t *device = (elxu_device_t *)ctx;
1054 
1055  if (device->driver == DEVICE_DRIVER_OCS) {
1057 
1058  helper_trace("%-16s: offset x%x\n", __func__, offset);
1059 
1060  memset(&cmd, 0, sizeof(cmd));
1062  cmd.offset = offset;
1063 
1064  rc = elxu_ioctl_device(device, OCS_IOCTL_CMD_ECD_HELPER, &cmd);
1065  if (rc == 0) {
1066  *pdata = cmd.data;
1067  }
1068  } else if (device->driver == DEVICE_DRIVER_PT) {
1069  elx_pt_ioctl_ecd_helper_t cmd;
1070 
1071  memset(&cmd, 0, sizeof(cmd));
1072  cmd.cmd = ELX_PT_ECD_HELPER_CFG_READ32;
1073  cmd.offset = offset;
1074 
1075  rc = elxu_ioctl_device(device, IOCTL_CMD_ELX_PT_ECD_HELPER, &cmd);
1076 
1077  if (rc == 0) {
1078  *pdata = cmd.data;
1079  }
1080  }
1081 }
1082 
1083 void os_cfg_write8 (void *ctx, uint32_t offset, uint32_t data)
1084 {
1085  elxu_device_t *device = (elxu_device_t *)ctx;
1086 
1087  if (device->driver == DEVICE_DRIVER_OCS) {
1089 
1090  helper_trace("%-16s: offset x%x\n", __func__, offset);
1091 
1092  memset(&cmd, 0, sizeof(cmd));
1094  cmd.offset = offset;
1095  cmd.data = data;
1096 
1098  } else if (device->driver == DEVICE_DRIVER_PT) {
1099  elx_pt_ioctl_ecd_helper_t cmd;
1100 
1101  helper_trace("%-16s: offset x%x\n", __func__, offset);
1102 
1103  memset(&cmd, 0, sizeof(cmd));
1104  cmd.cmd = ELX_PT_ECD_HELPER_CFG_WRITE8;
1105  cmd.offset = offset;
1106  cmd.data = data;
1107 
1108  elxu_ioctl_device(device, IOCTL_CMD_ELX_PT_ECD_HELPER, &cmd);
1109  }
1110 }
1111 
1112 void os_cfg_write16(void *ctx, uint32_t offset, uint32_t data)
1113 {
1114  elxu_device_t *device = (elxu_device_t *)ctx;
1115 
1116  if (device->driver == DEVICE_DRIVER_OCS) {
1118 
1119  helper_trace("%-16s: offset x%x\n", __func__, offset);
1120 
1121  memset(&cmd, 0, sizeof(cmd));
1123  cmd.offset = offset;
1124  cmd.data = data;
1125 
1127  } else if (device->driver == DEVICE_DRIVER_PT) {
1128  elx_pt_ioctl_ecd_helper_t cmd;
1129 
1130  helper_trace("%-16s: offset x%x\n", __func__, offset);
1131 
1132  memset(&cmd, 0, sizeof(cmd));
1133  cmd.cmd = ELX_PT_ECD_HELPER_CFG_WRITE16;
1134  cmd.offset = offset;
1135  cmd.data = data;
1136 
1137  elxu_ioctl_device(device, IOCTL_CMD_ELX_PT_ECD_HELPER, &cmd);
1138  }
1139 }
1140 void os_cfg_write32(void *ctx, uint32_t offset, uint32_t data)
1141 {
1142  elxu_device_t *device = (elxu_device_t *)ctx;
1143 
1144  if (device->driver == DEVICE_DRIVER_OCS) {
1146 
1147  helper_trace("%-16s: offset x%x\n", __func__, offset);
1148 
1149  memset(&cmd, 0, sizeof(cmd));
1151  cmd.offset = offset;
1152  cmd.data = data;
1153 
1155  } else {
1156  elx_pt_ioctl_ecd_helper_t cmd;
1157 
1158  helper_trace("%-16s: offset x%x\n", __func__, offset);
1159 
1160  memset(&cmd, 0, sizeof(cmd));
1161  cmd.cmd = ELX_PT_ECD_HELPER_CFG_WRITE16;
1162  cmd.offset = offset;
1163  cmd.data = data;
1164 
1165  elxu_ioctl_device(device, IOCTL_CMD_ELX_PT_ECD_HELPER, &cmd);
1166  }
1167 }
1168 
1169 void os_bar_read8 (void *ctx, uint32_t bar, uint32_t offset, uint32_t *pdata)
1170 {
1171  int32_t rc;
1172  elxu_device_t *device = (elxu_device_t *)ctx;
1173 
1174  if (device->driver == DEVICE_DRIVER_OCS) {
1176 
1177  helper_trace("%-16s: bar %d offset x%x\n", __func__, bar, offset);
1178 
1179  memset(&cmd, 0, sizeof(cmd));
1181  cmd.bar = bar;
1182  cmd.offset = offset;
1183 
1184  rc = elxu_ioctl_device(device, OCS_IOCTL_CMD_ECD_HELPER, &cmd);
1185  if (rc == 0)
1186  *pdata = cmd.data;
1187  } else if (device->driver == DEVICE_DRIVER_PT) {
1188  elx_pt_ioctl_ecd_helper_t cmd;
1189 
1190  helper_trace("%-16s: bar %d offset x%x\n", __func__, bar, offset);
1191 
1192  memset(&cmd, 0, sizeof(cmd));
1193  cmd.cmd = ELX_PT_ECD_HELPER_BAR_READ8;
1194  cmd.bar = bar;
1195  cmd.offset = offset;
1196 
1197  rc = elxu_ioctl_device(device, IOCTL_CMD_ELX_PT_ECD_HELPER, &cmd);
1198  if (rc == 0)
1199  *pdata = cmd.data;
1200  }
1201 }
1202 
1203 void os_bar_read16(void *ctx, uint32_t bar, uint32_t offset, uint32_t *pdata)
1204 {
1205  int32_t rc;
1206  elxu_device_t *device = (elxu_device_t *)ctx;
1207 
1208  if (device->driver == DEVICE_DRIVER_OCS) {
1210 
1211  helper_trace("%-16s: bar %d offset x%x\n", __func__, bar, offset);
1212 
1213  memset(&cmd, 0, sizeof(cmd));
1215  cmd.bar = bar;
1216  cmd.offset = offset;
1217 
1218  rc = elxu_ioctl_device(device, OCS_IOCTL_CMD_ECD_HELPER, &cmd);
1219  if (rc == 0)
1220  *pdata = cmd.data;
1221  } else if (device->driver == DEVICE_DRIVER_PT) {
1222  elx_pt_ioctl_ecd_helper_t cmd;
1223 
1224  helper_trace("%-16s: bar %d offset x%x\n", __func__, bar, offset);
1225 
1226  memset(&cmd, 0, sizeof(cmd));
1227  cmd.cmd = ELX_PT_ECD_HELPER_BAR_READ16;
1228  cmd.bar = bar;
1229  cmd.offset = offset;
1230 
1231  rc = elxu_ioctl_device(device, IOCTL_CMD_ELX_PT_ECD_HELPER, &cmd);
1232  if (rc == 0)
1233  *pdata = cmd.data;
1234  }
1235 }
1236 
1237 void os_bar_read32(void *ctx, uint32_t bar, uint32_t offset, uint32_t *pdata)
1238 {
1239  int32_t rc;
1240  elxu_device_t *device = (elxu_device_t *)ctx;
1241 
1242  if (device->driver == DEVICE_DRIVER_OCS) {
1244 
1245  helper_trace("%-16s: bar %d offset x%x\n", __func__, bar, offset);
1246 
1247  memset(&cmd, 0, sizeof(cmd));
1249  cmd.bar = bar;
1250  cmd.offset = offset;
1251 
1252  rc = elxu_ioctl_device(device, OCS_IOCTL_CMD_ECD_HELPER, &cmd);
1253  if (rc == 0)
1254  *pdata = cmd.data;
1255  } else if (device->driver == DEVICE_DRIVER_PT) {
1256  elx_pt_ioctl_ecd_helper_t cmd;
1257 
1258  helper_trace("%-16s: bar %d offset x%x\n", __func__, bar, offset);
1259 
1260  memset(&cmd, 0, sizeof(cmd));
1261  cmd.cmd = ELX_PT_ECD_HELPER_BAR_READ32;
1262  cmd.bar = bar;
1263  cmd.offset = offset;
1264 
1265  rc = elxu_ioctl_device(device, IOCTL_CMD_ELX_PT_ECD_HELPER, &cmd);
1266  if (rc == 0)
1267  *pdata = cmd.data;
1268  }
1269 }
1270 
1271 void os_bar_write8 (void *ctx, uint32_t bar, uint32_t offset, uint32_t data)
1272 {
1273  elxu_device_t *device = (elxu_device_t *)ctx;
1274 
1275  if (device->driver == DEVICE_DRIVER_OCS) {
1277 
1278  helper_trace("%-16s: bar %d offset x%x\n", __func__, bar, offset);
1279 
1280  memset(&cmd, 0, sizeof(cmd));
1282  cmd.bar = bar;
1283  cmd.offset = offset;
1284  cmd.data = data;
1285 
1287  } else if (device->driver == DEVICE_DRIVER_PT) {
1288  elx_pt_ioctl_ecd_helper_t cmd;
1289 
1290  helper_trace("%-16s: bar %d offset x%x\n", __func__, bar, offset);
1291 
1292  memset(&cmd, 0, sizeof(cmd));
1293  cmd.cmd = ELX_PT_ECD_HELPER_BAR_WRITE8;
1294  cmd.bar = bar;
1295  cmd.offset = offset;
1296  cmd.data = data;
1297 
1298  elxu_ioctl_device(device, IOCTL_CMD_ELX_PT_ECD_HELPER, &cmd);
1299  }
1300 }
1301 
1302 void os_bar_write16(void *ctx, uint32_t bar, uint32_t offset, uint32_t data)
1303 {
1304  elxu_device_t *device = (elxu_device_t *)ctx;
1305 
1306  if (device->driver == DEVICE_DRIVER_OCS) {
1308 
1309  helper_trace("%-16s: bar %d offset x%x\n", __func__, bar, offset);
1310 
1311  memset(&cmd, 0, sizeof(cmd));
1313  cmd.bar = bar;
1314  cmd.offset = offset;
1315  cmd.data = data;
1316 
1318  } else if (device->driver == DEVICE_DRIVER_PT) {
1319  elx_pt_ioctl_ecd_helper_t cmd;
1320 
1321  helper_trace("%-16s: bar %d offset x%x\n", __func__, bar, offset);
1322 
1323  memset(&cmd, 0, sizeof(cmd));
1324  cmd.cmd = ELX_PT_ECD_HELPER_BAR_WRITE16;
1325  cmd.bar = bar;
1326  cmd.offset = offset;
1327  cmd.data = data;
1328 
1329  elxu_ioctl_device(device, IOCTL_CMD_ELX_PT_ECD_HELPER, &cmd);
1330  }
1331 }
1332 
1333 void os_bar_write32(void *ctx, uint32_t bar, uint32_t offset, uint32_t data)
1334 {
1335  elxu_device_t *device = (elxu_device_t *)ctx;
1336 
1337  if (device->driver == DEVICE_DRIVER_OCS) {
1339 
1340  helper_trace("%-16s: bar %d offset x%x\n", __func__, bar, offset);
1341 
1342  memset(&cmd, 0, sizeof(cmd));
1344  cmd.bar = bar;
1345  cmd.offset = offset;
1346  cmd.data = data;
1347 
1349  helper_trace("%-16s: done\n", __func__);
1350  } else {
1351  elx_pt_ioctl_ecd_helper_t cmd;
1352 
1353  helper_trace("%-16s: bar %d offset x%x\n", __func__, bar, offset);
1354 
1355  memset(&cmd, 0, sizeof(cmd));
1356  cmd.cmd = ELX_PT_ECD_HELPER_BAR_WRITE32;
1357  cmd.bar = bar;
1358  cmd.offset = offset;
1359  cmd.data = data;
1360 
1361  elxu_ioctl_device(device, IOCTL_CMD_ELX_PT_ECD_HELPER, &cmd);
1362  }
1363 }
1364 
1365 void *os_malloc(void *ctx, uint32_t size)
1366 {
1367  return malloc(size);
1368 }
1369 void os_free(void *ctx, void *ptr)
1370 {
1371  return free(ptr);
1372 }
1373 
ext_fat_mode_t mode_trace_level[1]
Definition: elxu_sli4.h:763
int elxu_core_dump(elxu_device_t *device_p, char *fname_p, int test_dump)
Core Dump functionality.
Definition: elxu_dump.c:855
#define LOG_MODE_RAM_MASK
Definition: elxu_sli4.h:775
int hba_data_upload(elxu_device_t *device_p, char const *fname_p, data_type_req_t req)
FAT data upload functionality.
Definition: elxu_dump.c:822
uint32_t elxu_get_asic_id(elxu_device_t *device)
Return the ASIC ID value for a device.
Definition: elxu_device.c:478
ocs_ecd_helper_cmd_t cmd
Definition: ecdtest.c:101
void os_bar_write8(void *ctx, uint32_t bar, uint32_t offset, uint32_t data)
Definition: elxu_dump.c:1271
int lancer_dump_to_host(elxu_device_t *device_p, const char *fname, int fdb_dump)
Trigger dump-to-host on Lancer.
Definition: elxu_dump.c:660
uint32_t max_logging_functions
Definition: elxu_sli4.h:770
uint32_t module_id
Definition: elxu_sli4.h:761
uint32_t max_logging_ports
Definition: elxu_sli4.h:771
int elxu_device_exec(elxu_device_t *device, char *name, void *arg_in, int arg_in_len, void *arg_out, int arg_out_len)
Execute a management function on a device.
Definition: elxu_device.c:952
void os_assert(char *message, uint32_t Line, char *File)
Definition: elxu_dump.c:978
int sli4_object_read(elxu_device_t *device, const char *objectName, void *buffer, uint32_t bufferLength)
Read data from an object.
Definition: elxu_lancer.c:333
void os_cfg_read16(void *ctx, uint32_t offset, uint32_t *pdata)
Definition: elxu_dump.c:1019
ocs_ioctl_ddump_arg_t args
Definition: ocs_ioctl.h:326
static int elxu_test_file_write(const char *filename)
test write permissions for given file
Definition: elxu_dump.c:65
void os_bar_read16(void *ctx, uint32_t bar, uint32_t offset, uint32_t *pdata)
Definition: elxu_dump.c:1203
uint8_t module_str[32]
Definition: elxu_sli4.h:760
void os_bar_read8(void *ctx, uint32_t bar, uint32_t offset, uint32_t *pdata)
Definition: elxu_dump.c:1169
#define OCS_IOCTL_CMD_ECD_HELPER
Definition: ecdtest.c:110
uint32_t num_modes
Definition: elxu_sli4.h:762
int elxu_get_fw_diagnostic_log(elxu_device_t *device_p, char const *fname)
gather firmware diagnostic logs
Definition: elxu_dump.c:765
void os_cfg_write16(void *ctx, uint32_t offset, uint32_t data)
Definition: elxu_dump.c:1112
int fat_info(elxu_device_t *device)
Return length of FAT.
Definition: elxu_sky.c:156
static int ext_fat_generate_efd_file(elxu_device_t *device_p, char const *fname_p)
EXT FAT data upload functionality.
Definition: elxu_dump.c:448
#define LOG_MODE_NWTK_MASK
Definition: elxu_sli4.h:777
void * zmalloc(uint32_t len)
Allocates and zeroes memory to be used.
Definition: elxu_common.c:63
static int ext_fat_snapshot_upload(elxu_device_t *device_p, char const *fname_p)
EXT FAT data upload functionality.
Definition: elxu_dump.c:382
#define LOG_MODE_NVRAM_MASK
Definition: elxu_sli4.h:776
void os_bar_read32(void *ctx, uint32_t bar, uint32_t offset, uint32_t *pdata)
Definition: elxu_dump.c:1237
int ext_fat_capabilities_upld(elxu_device_t *device_p)
Displays EXT FAT capabilities.
Definition: elxu_dump.c:309
#define ECD_MIN_BUFFER_SIZE
Definition: ecd_api.h:42
uint32_t ioctl_high_version
Definition: ecd_api.h:58
int fat_read(elxu_device_t *device, uint8_t *buffer, uint32_t bufferLength)
Read FAT.
Definition: elxu_sky.c:175
int get_ext_fat_capabilities(elxu_device_t *device, uint32_t parameter_type, ext_fat_config_params_t *params, uint32_t paramsLength)
Issue EFD get capabilities mailbox command.
Definition: elxu_sky.c:236
#define DEFAULT_OUTPUT_FILE_NAME
Definition: elxu_dump.h:36
void os_stall(void *ctx, uint32_t usecTime)
Definition: elxu_dump.c:984
int ext_fat_retrieve_snapshot(elxu_device_t *device, uint8_t *buf, uint32_t len, uint32_t numlogs)
Issue retrieve EFD snapshot mailbox command.
Definition: elxu_sky.c:304
#define OCS_IOCTL_CMD_GET_DDUMP
Definition: ocs_ioctl.h:489
int elxu_ioctl_device(elxu_device_t *device, int req, void *arg)
Send an ioctl to a device.
Definition: elxu_device.c:322
void zfree(void *p)
Frees memory that has been allocated.
Definition: elxu_common.c:80
int is_lancer(elxu_device_t *device_p)
Return true IFF the HBA is a Lancer.
Definition: elxu_device.c:1236
void os_cfg_read32(void *ctx, uint32_t offset, uint32_t *pdata)
Definition: elxu_dump.c:1050
uint32_t bytes_written
Definition: ocs_ioctl.h:329
int ext_fat_read_string_table_upld(elxu_device_t *device_p, char const *fname_p)
FAT data upload functionality.
Definition: elxu_dump.c:216
int ext_fat_read_string_table(elxu_device_t *device, mbox_ext_fat_read_string_params_t *tblinfo, uint32_t tbl_info_len, uint32_t bytes_to_read, uint32_t bytes_read)
Issue EXT_FAT_READ_STRING_TABLE mailbox command.
Definition: elxu_sky.c:387
ecd_fwState_t
Definition: ecd_api.h:36
uint8_t * user_buffer
Definition: ocs_ioctl.h:327
uint32_t ioctl_low_version
Definition: ecd_api.h:57
int sli4_object_delete(elxu_device_t *device, const char *objectName)
Deletes an SLI4 object.
Definition: elxu_lancer.c:214
void os_bar_write16(void *ctx, uint32_t bar, uint32_t offset, uint32_t data)
Definition: elxu_dump.c:1302
void os_cfg_write32(void *ctx, uint32_t offset, uint32_t data)
Definition: elxu_dump.c:1140
uint32_t sli_intf
Definition: ecd_api.h:59
void elxu_driver_dump(elxu_device_t *device, int bufsize, ocs_ioctl_ddump_arg_t *args)
Definition: elxu_dump.c:163
int lancer_gen_dump(elxu_device_t *device_p, int fdb_dump)
Trigger dump generation on Lancer.
Definition: elxu_dump.c:630
#define MAX_FW_LOG_BUFFER_SIZE
int sli4_object_length(elxu_device_t *device, const char *objectName)
Return an SLI4 object&#39;s length in bytes.
Definition: elxu_lancer.c:271
uint32_t deviceIndex
Definition: elxu_device.h:85
char system_name[128]
Definition: ecd_api.h:56
void os_free(void *ctx, void *ptr)
Definition: elxu_dump.c:1369
int is_skyhawk(elxu_device_t *device_p)
Return true IFF the HBA is a Skyhawk.
Definition: elxu_device.c:1219
char * elxu_device_get_value(elxu_device_t *device, char *key)
Return a property value for a device.
Definition: elxu_device.c:765
OCS_CTL_CMD_GET_DDUMP ioctl structure.
Definition: ocs_ioctl.h:325
uint32_t os_minor
Definition: ecd_api.h:54
#define ARRAY_SIZE(x)
Definition: elxu_common.h:46
#define MALLOC_FAILED
Definition: elxu.h:42
void os_bar_write32(void *ctx, uint32_t bar, uint32_t offset, uint32_t data)
Definition: elxu_dump.c:1333
uint32_t instance
Definition: ecd_api.h:52
static int enable_helper_trace
Definition: elxu_dump.c:960
uint32_t elxu_get_sliintf(elxu_device_t *device)
Return the sli_intf value for a device.
Definition: elxu_device.c:462
ocs_ddump_action_t action
Definition: ocs_ioctl.h:316
ext_fat_module_t debug_module[1]
Definition: elxu_sli4.h:779
uint32_t asic_id
Definition: ecd_api.h:60
int ecd_GetCoreDumpData(void *dumpCtx, ecd_fwState_t fwState, ecd_get_params_t *params, void *dumpBuffer, int dumpBufferSize, int argc, char *argv[])
Fetch coreDump data.
static size_t ocs_write_buffer_to_file(const char *ofname, void *src_buffer, size_t byte_count)
Definition: elxu_dump.c:743
int is_prism(elxu_device_t *device_p)
Return true IFF the HBA is a Prism.
Definition: elxu_device.c:1270
void ecd_log(char *fmt,...)
Definition: elxu_dump.c:969
OCS_IOCTL_CMD_ECD_HELPER ioctl structure.
Definition: ecdtest.c:100
#define helper_trace(fmt,...)
Definition: elxu_dump.c:962
uint32_t user_buffer_len
Definition: ocs_ioctl.h:328
int hba_data_object_upload(elxu_device_t *device_p, char const *objname_p, char const *fname_p)
Definition: elxu_dump.c:564
void * os_malloc(void *ctx, uint32_t size)
Definition: elxu_dump.c:1365
char os_name[128]
Definition: ecd_api.h:55
static int lancer_hba_dump_upload(elxu_device_t *device_p, char const *fname_p)
Lancer dump data upload functionality.
Definition: elxu_dump.c:488
elxu_device_driver_e driver
Definition: elxu_device.h:90
static int fat_upload(elxu_device_t *device_p, char const *fname_p)
FAT data upload functionality.
Definition: elxu_dump.c:83
int ext_fat_config_snapshot(elxu_device_t *device)
Issue configure EFD snapshot mailbox command.
Definition: elxu_sky.c:268
#define LOG_MODE_UART_MASK
Definition: elxu_sli4.h:774
void os_cfg_read8(void *ctx, uint32_t offset, uint32_t *pdata)
Definition: elxu_dump.c:989
uint32_t os_major
Definition: ecd_api.h:53
void os_cfg_write8(void *ctx, uint32_t offset, uint32_t data)
Definition: elxu_dump.c:1083
data_type_req_t
Definition: elxu_dump.h:40
#define EXT_FAT_PARAM_TYPE_DEFAULT
Definition: elxu_sli4.h:788