44 #include <sys/ioctl.h>
45 #include <sys/utsname.h>
56 #include <elx_pt_ioctl.h>
67 out = fopen(filename,
"wb");
69 printf(
"Error: can't create file: %s\n", filename);
96 printf(
"Null pointer\n");
107 printf (
"Failed to open file for writing, file: %s\n", fname_p);
112 if ((fatLength =
fat_info(device_p)) < 0)
114 printf (
"Fetch FAT info failure \n");
120 printf (
"FAT fetch - nothing to retrieve\n");
124 printf (
"Fat length is %d bytes\n", fatLength);
128 if ((buf_p =
zmalloc(fatLength)) == NULL)
130 printf(
"Malloc failure - (%s)\n", strerror(errno));
135 if ((retval =
fat_read(device_p, buf_p, fatLength)) < 0)
137 printf (
"FAT read Failed with error code: %d\n", retval);
144 if ((fd = open(fname_p, O_CREAT | O_WRONLY, 0644)) < 0)
150 if (write(fd, buf_p, fatLength) < 0)
152 printf(
"write file failure, (%s)\n", strerror(errno));
171 fprintf(stderr,
"Invalid bufsize: %d\n", bufsize);
175 buf = malloc(bufsize+1);
177 fprintf(stderr,
"Unable to allocate buffer of %d KBytes\n", bufsize/1024);
181 memset(&req, 0,
sizeof(req));
198 printf(
"No driver-dump data returned\n");
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;
225 const char *filename =
"efdstr.data";
229 if ((tblinfo = malloc (tbl_info_len)) == NULL)
231 printf(
"Malloc failure - (%s)\n", strerror(errno));
240 printf (
"Filename :%s \n", fname_p);
244 if ((fd = open(fname_p, O_CREAT | O_WRONLY, 0644)) < 0)
246 printf(
"open file failure, (%s)\n", strerror(errno));
254 if ((fd1 = open(
"strTbl", O_CREAT | O_WRONLY, 0644)) < 0)
256 printf(
"open file failure, (%s)\n", strerror(errno));
262 memset (tblinfo, 0, tbl_info_len);
266 printf (
"Reading string table failed\n");
267 goto error_Cleanup_fd1;
272 printf(
"write file failure, (%s)\n", strerror(errno));
273 goto error_Cleanup_fd1;
278 printf(
"write file failure, (%s)\n", strerror(errno));
279 goto error_Cleanup_fd1;
284 }
while (remaining_bytes);
286 printf (
"String table was read successfully : %d Bytes \n", read_bytes);
311 uint32_t bufferLength = 3*1024+256;
315 if ((config =
zmalloc(bufferLength)) == NULL)
317 printf(
"Malloc failure - (%s)\n", strerror(errno));
325 printf (
"Error: rval %d\n", rval);
332 ext_fat_mode_t *mode;
339 printf(
"supported_modes %s%s%s%s\n",
351 printf(
"[%d]\t%-16s\tmodule_id %d\tnum_modes %d\n", i, module->
module_str,
356 printf(
"Error: suspected invalid num_modes - terminating dump\n");
359 for (j = 0; j < module->
num_modes; j ++, mode ++)
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);
390 printf (
"Error executing EFD config snapshot mailbox cmd.\n");
394 printf (
"EFD Snapshot size is %d logs\n", len);
398 printf(
"Malloc failure - (%s)\n", strerror(errno));
402 printf (
"Retrieve EFD snapshot \n");
405 printf (
"Retrieve failed\n");
410 const char *filename =
"efd.data";
419 if ((fd = open(fname_p, O_WRONLY| O_APPEND |O_CREAT, 0644)) < 0)
421 printf(
"open file failure, (%s)\n", strerror(errno));
428 printf(
"write file failure, (%s)\n", strerror(errno));
430 printf (
"EFD snapshot was retrieved successfully \n");
450 const char *filename =
"data.efd";
454 printf (
"Using generic file name - %s\n", filename);
460 printf (
"Failed to open file for writing, file: %s\n", fname_p);
466 printf (
"EFD String table retrieval failed \n");
472 printf (
"EFD Snapshot retrieval failed \n");
490 const char *ofname =
"dump.bin";
491 const char *objectName =
"/dbg/dump.bin";
502 printf (
"Failed to open file for writing, file: %s\n", ofname);
510 printf(
"Error: sli4_object_length(%s) returned %d\n", objectName, rval);
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);
521 void *buffer = malloc(objectLength);
524 printf(
"Malloc failure - (%s)\n", strerror(errno));
531 printf(
"Error: sli4_object_read(%s) failed: %d\n", objectName, rval);
535 out = fopen(ofname,
"wb");
538 written = fwrite(buffer, objectLength, 1, out);
540 printf (
"File %s created\n", ofname);
545 printf (
"Failed to delete object %s from SLI device\n", objectName);
548 printf (
"Object %s was deleted from SLI device\n", objectName);
552 printf(
"Failed to write to file: %s\n", ofname);
556 printf(
"Failed to write to file: %s\n", ofname);
566 const char *ofname =
"object.bin";
567 const char *objectName = objname_p;
578 printf (
"Failed to open file for writing, file: %s\n", ofname);
582 printf (
"object name : %s \n", objname_p);
587 printf(
"Error: sli4_object_length(%s) returned %d\n", objectName, rval);
591 uint32_t objectLength = rval;
592 printf (
"Length of object is %d\n", objectLength);
594 void *buffer = malloc(objectLength);
597 printf(
"Malloc failure - (%s)\n", strerror(errno));
604 printf(
"Error: sli4_object_read(%s) failed: %d\n", objectName, rval);
608 printf(
"rval %d\n", rval);
611 out = fopen(ofname,
"wb");
614 fwrite(buffer, objectLength, 1, out);
616 printf (
"File %s created\n", ofname);
634 printf(
"Generating dump..\n");
636 rc =
elxu_device_exec(device_p,
"/ocs/driver/fdb_gendump", NULL, 0, NULL, 0);
643 printf(
"Dump successfully generated and can now be read from SLI device\n");
645 printf(
"Dump generation failed.\n");
663 uint8_t *dump_buffer;
664 const char *ofname =
"dump.bin";
666 uint32_t actual_size;
667 uint8_t *response_bytes;
668 uint32_t max_dump_size = 0;
677 printf (
"Failed to open file for writing, file: %s\n", ofname);
682 if (!max_dump_size) {
683 printf(
"Unable to determine the size of dump \n");
687 dump_buffer = malloc(max_dump_size);
688 if (dump_buffer == NULL) {
693 printf(
"Starting dump...\n");
696 rc =
elxu_device_exec(device_p,
"/ocs/driver/fdb_dump_to_host", NULL, 0, dump_buffer, max_dump_size);
698 rc =
elxu_device_exec(device_p,
"/ocs/driver/dump_to_host", NULL, 0, dump_buffer, max_dump_size);
703 printf(
"Dump generation failed.\n");
710 response_bytes = dump_buffer;
711 actual_size = (response_bytes[0] << 24) |
712 (response_bytes[1] << 16) |
713 (response_bytes[2] << 8) |
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;
721 out = fopen(ofname,
"wb");
725 written = fwrite(dump_buffer, actual_size, 1, out);
727 printf (
"File %s created\n", ofname);
728 if (dump_buffer == NULL)
729 printf(
"Dump buffer is NULL\n");
732 printf(
"Failed to write to file: %s\n", ofname);
734 printf(
"Dump written to file %s\n", ofname);
748 fp = fopen(ofname,
"wb");
751 written = fwrite(src_buffer, byte_count, 1, fp);
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;
771 uint32_t bytes_copied = 0;
781 printf (
"Failed to open file, %s for writing\n", fname);
785 diag_log_buffer = malloc(buffer_size);
786 if (diag_log_buffer == NULL) {
787 perror(
"malloc : fw diagnostic log buffer");
791 rc =
elxu_device_exec(device_p,
"/ocs/driver/fw_diag_log", NULL, 0, diag_log_buffer, buffer_size);
793 printf(
"FW diagnostic logs copy failed, rc %d.\n", rc);
797 bytes_copied = *((uint32_t *)diag_log_buffer);
803 printf(
"Wrote %d bytes of firmware diagnostic log to %s\n", bytes_copied, fname);
807 zfree(diag_log_buffer);
839 printf (
"Unknown HBA \n");
863 char *sky_template_ecdargs[] = {
"dead",
"skytemplate"};
864 char *test_template_ecdargs[] = {
"dead",
"testtemplate"};
866 uint32_t ecdargs_count =
ARRAY_SIZE(sky_template_ecdargs);
867 struct utsname utsname;
874 if (fname_p == NULL) {
875 fname_p =
"dump.core";
880 printf (
"Failed to open file for writing, file: %s\n", fname_p);
885 memset(¶ms, 0,
sizeof(params));
889 ecdargs = test_template_ecdargs;
890 ecdargs_count =
ARRAY_SIZE(test_template_ecdargs);
892 ecdargs = sky_template_ecdargs;
893 ecdargs_count =
ARRAY_SIZE(sky_template_ecdargs);
899 rc = uname(&utsname);
912 sscanf(utsname.release,
"%d.%d.%d", &major, &minor, &release);
920 buffer = malloc(bufferLength);
923 printf(
"Error: coredump malloc (%d) failed\n", bufferLength);
927 ecdargs_count, ecdargs);
929 printf(
"ecd_GetCoreDumpData returned %d\n", rc);
933 if ((rc > 0) && (fname_p != NULL)) {
937 out = fopen(fname_p,
"wb");
939 printf(
"Error: can't create %s\n", fname_p);
941 rc = fwrite(buffer, 1, len, out);
943 printf(
"Error: fwrite failed: %d\n", rc);
962 #define helper_trace(fmt, ...) \
964 if (enable_helper_trace) \
965 printf(fmt, ##__VA_ARGS__); \
978 void os_assert(
char *message, uint32_t Line,
char *File)
980 ecd_log(
"%s(%d) %s\n", File, Line, message);
999 memset(&cmd, 0,
sizeof(cmd));
1006 elx_pt_ioctl_ecd_helper_t cmd;
1010 memset(&cmd, 0,
sizeof(cmd));
1011 cmd.cmd = ELX_PT_ECD_HELPER_CFG_READ8;
1012 cmd.offset = offset;
1029 memset(&cmd, 0,
sizeof(cmd));
1037 elx_pt_ioctl_ecd_helper_t cmd;
1041 memset(&cmd, 0,
sizeof(cmd));
1042 cmd.cmd = ELX_PT_ECD_HELPER_CFG_READ16;
1043 cmd.offset = offset;
1060 memset(&cmd, 0,
sizeof(cmd));
1069 elx_pt_ioctl_ecd_helper_t cmd;
1071 memset(&cmd, 0,
sizeof(cmd));
1072 cmd.cmd = ELX_PT_ECD_HELPER_CFG_READ32;
1073 cmd.offset = offset;
1092 memset(&cmd, 0,
sizeof(cmd));
1099 elx_pt_ioctl_ecd_helper_t cmd;
1103 memset(&cmd, 0,
sizeof(cmd));
1104 cmd.cmd = ELX_PT_ECD_HELPER_CFG_WRITE8;
1105 cmd.offset = offset;
1121 memset(&cmd, 0,
sizeof(cmd));
1128 elx_pt_ioctl_ecd_helper_t cmd;
1132 memset(&cmd, 0,
sizeof(cmd));
1133 cmd.cmd = ELX_PT_ECD_HELPER_CFG_WRITE16;
1134 cmd.offset = offset;
1149 memset(&cmd, 0,
sizeof(cmd));
1156 elx_pt_ioctl_ecd_helper_t cmd;
1160 memset(&cmd, 0,
sizeof(cmd));
1161 cmd.cmd = ELX_PT_ECD_HELPER_CFG_WRITE16;
1162 cmd.offset = offset;
1169 void os_bar_read8 (
void *ctx, uint32_t bar, uint32_t offset, uint32_t *pdata)
1177 helper_trace(
"%-16s: bar %d offset x%x\n", __func__, bar, offset);
1179 memset(&cmd, 0,
sizeof(cmd));
1188 elx_pt_ioctl_ecd_helper_t cmd;
1190 helper_trace(
"%-16s: bar %d offset x%x\n", __func__, bar, offset);
1192 memset(&cmd, 0,
sizeof(cmd));
1193 cmd.cmd = ELX_PT_ECD_HELPER_BAR_READ8;
1195 cmd.offset = offset;
1211 helper_trace(
"%-16s: bar %d offset x%x\n", __func__, bar, offset);
1213 memset(&cmd, 0,
sizeof(cmd));
1222 elx_pt_ioctl_ecd_helper_t cmd;
1224 helper_trace(
"%-16s: bar %d offset x%x\n", __func__, bar, offset);
1226 memset(&cmd, 0,
sizeof(cmd));
1227 cmd.cmd = ELX_PT_ECD_HELPER_BAR_READ16;
1229 cmd.offset = offset;
1245 helper_trace(
"%-16s: bar %d offset x%x\n", __func__, bar, offset);
1247 memset(&cmd, 0,
sizeof(cmd));
1256 elx_pt_ioctl_ecd_helper_t cmd;
1258 helper_trace(
"%-16s: bar %d offset x%x\n", __func__, bar, offset);
1260 memset(&cmd, 0,
sizeof(cmd));
1261 cmd.cmd = ELX_PT_ECD_HELPER_BAR_READ32;
1263 cmd.offset = offset;
1278 helper_trace(
"%-16s: bar %d offset x%x\n", __func__, bar, offset);
1280 memset(&cmd, 0,
sizeof(cmd));
1288 elx_pt_ioctl_ecd_helper_t cmd;
1290 helper_trace(
"%-16s: bar %d offset x%x\n", __func__, bar, offset);
1292 memset(&cmd, 0,
sizeof(cmd));
1293 cmd.cmd = ELX_PT_ECD_HELPER_BAR_WRITE8;
1295 cmd.offset = offset;
1309 helper_trace(
"%-16s: bar %d offset x%x\n", __func__, bar, offset);
1311 memset(&cmd, 0,
sizeof(cmd));
1319 elx_pt_ioctl_ecd_helper_t cmd;
1321 helper_trace(
"%-16s: bar %d offset x%x\n", __func__, bar, offset);
1323 memset(&cmd, 0,
sizeof(cmd));
1324 cmd.cmd = ELX_PT_ECD_HELPER_BAR_WRITE16;
1326 cmd.offset = offset;
1340 helper_trace(
"%-16s: bar %d offset x%x\n", __func__, bar, offset);
1342 memset(&cmd, 0,
sizeof(cmd));
1351 elx_pt_ioctl_ecd_helper_t cmd;
1353 helper_trace(
"%-16s: bar %d offset x%x\n", __func__, bar, offset);
1355 memset(&cmd, 0,
sizeof(cmd));
1356 cmd.cmd = ELX_PT_ECD_HELPER_BAR_WRITE32;
1358 cmd.offset = offset;
1367 return malloc(size);
ext_fat_mode_t mode_trace_level[1]
int elxu_core_dump(elxu_device_t *device_p, char *fname_p, int test_dump)
Core Dump functionality.
#define LOG_MODE_RAM_MASK
int hba_data_upload(elxu_device_t *device_p, char const *fname_p, data_type_req_t req)
FAT data upload functionality.
uint32_t elxu_get_asic_id(elxu_device_t *device)
Return the ASIC ID value for a device.
void os_bar_write8(void *ctx, uint32_t bar, uint32_t offset, uint32_t data)
int lancer_dump_to_host(elxu_device_t *device_p, const char *fname, int fdb_dump)
Trigger dump-to-host on Lancer.
uint32_t max_logging_functions
uint32_t max_logging_ports
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.
void os_assert(char *message, uint32_t Line, char *File)
int sli4_object_read(elxu_device_t *device, const char *objectName, void *buffer, uint32_t bufferLength)
Read data from an object.
void os_cfg_read16(void *ctx, uint32_t offset, uint32_t *pdata)
ocs_ioctl_ddump_arg_t args
static int elxu_test_file_write(const char *filename)
test write permissions for given file
void os_bar_read16(void *ctx, uint32_t bar, uint32_t offset, uint32_t *pdata)
void os_bar_read8(void *ctx, uint32_t bar, uint32_t offset, uint32_t *pdata)
#define OCS_IOCTL_CMD_ECD_HELPER
int elxu_get_fw_diagnostic_log(elxu_device_t *device_p, char const *fname)
gather firmware diagnostic logs
void os_cfg_write16(void *ctx, uint32_t offset, uint32_t data)
int fat_info(elxu_device_t *device)
Return length of FAT.
static int ext_fat_generate_efd_file(elxu_device_t *device_p, char const *fname_p)
EXT FAT data upload functionality.
#define LOG_MODE_NWTK_MASK
void * zmalloc(uint32_t len)
Allocates and zeroes memory to be used.
static int ext_fat_snapshot_upload(elxu_device_t *device_p, char const *fname_p)
EXT FAT data upload functionality.
#define LOG_MODE_NVRAM_MASK
void os_bar_read32(void *ctx, uint32_t bar, uint32_t offset, uint32_t *pdata)
int ext_fat_capabilities_upld(elxu_device_t *device_p)
Displays EXT FAT capabilities.
#define ECD_MIN_BUFFER_SIZE
uint32_t ioctl_high_version
int fat_read(elxu_device_t *device, uint8_t *buffer, uint32_t bufferLength)
Read FAT.
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.
#define DEFAULT_OUTPUT_FILE_NAME
void os_stall(void *ctx, uint32_t usecTime)
int ext_fat_retrieve_snapshot(elxu_device_t *device, uint8_t *buf, uint32_t len, uint32_t numlogs)
Issue retrieve EFD snapshot mailbox command.
#define OCS_IOCTL_CMD_GET_DDUMP
int elxu_ioctl_device(elxu_device_t *device, int req, void *arg)
Send an ioctl to a device.
void zfree(void *p)
Frees memory that has been allocated.
int is_lancer(elxu_device_t *device_p)
Return true IFF the HBA is a Lancer.
void os_cfg_read32(void *ctx, uint32_t offset, uint32_t *pdata)
uint32_t num_returned_bytes
int ext_fat_read_string_table_upld(elxu_device_t *device_p, char const *fname_p)
FAT data upload functionality.
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.
uint32_t num_remaining_bytes
uint32_t ioctl_low_version
int sli4_object_delete(elxu_device_t *device, const char *objectName)
Deletes an SLI4 object.
void os_bar_write16(void *ctx, uint32_t bar, uint32_t offset, uint32_t data)
void os_cfg_write32(void *ctx, uint32_t offset, uint32_t data)
void elxu_driver_dump(elxu_device_t *device, int bufsize, ocs_ioctl_ddump_arg_t *args)
int lancer_gen_dump(elxu_device_t *device_p, int fdb_dump)
Trigger dump generation on Lancer.
#define MAX_FW_LOG_BUFFER_SIZE
int sli4_object_length(elxu_device_t *device, const char *objectName)
Return an SLI4 object's length in bytes.
void os_free(void *ctx, void *ptr)
int is_skyhawk(elxu_device_t *device_p)
Return true IFF the HBA is a Skyhawk.
char * elxu_device_get_value(elxu_device_t *device, char *key)
Return a property value for a device.
OCS_CTL_CMD_GET_DDUMP ioctl structure.
void os_bar_write32(void *ctx, uint32_t bar, uint32_t offset, uint32_t data)
static int enable_helper_trace
uint32_t elxu_get_sliintf(elxu_device_t *device)
Return the sli_intf value for a device.
ocs_ddump_action_t action
ext_fat_module_t debug_module[1]
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)
int is_prism(elxu_device_t *device_p)
Return true IFF the HBA is a Prism.
void ecd_log(char *fmt,...)
OCS_IOCTL_CMD_ECD_HELPER ioctl structure.
#define helper_trace(fmt,...)
int hba_data_object_upload(elxu_device_t *device_p, char const *objname_p, char const *fname_p)
void * os_malloc(void *ctx, uint32_t size)
static int lancer_hba_dump_upload(elxu_device_t *device_p, char const *fname_p)
Lancer dump data upload functionality.
elxu_device_driver_e driver
static int fat_upload(elxu_device_t *device_p, char const *fname_p)
FAT data upload functionality.
int ext_fat_config_snapshot(elxu_device_t *device)
Issue configure EFD snapshot mailbox command.
#define LOG_MODE_UART_MASK
void os_cfg_read8(void *ctx, uint32_t offset, uint32_t *pdata)
void os_cfg_write8(void *ctx, uint32_t offset, uint32_t data)
#define EXT_FAT_PARAM_TYPE_DEFAULT