Roland,
This patch adds more output when "-v" is specified and adds details
to output from some of the error cases.

BTW, this is the version of code I used to flash all my
cards to v3.3.2 on rx2600 and rx4640 (HP IA64/ZX1 boxen).

thanks,
grant

Signed-off-by: Grant Grundler <[EMAIL PROTECTED]>

Index: src/userspace/tvflash/src/tvflash.c
===================================================================
--- src/userspace/tvflash/src/tvflash.c (revision 2103)
+++ src/userspace/tvflash/src/tvflash.c (working copy)
@@ -460,6 +460,9 @@ static int open_hca(struct tvdevice *tvd
 {
        cur_hca = tvdev->pdev;
 
+       if (verbose)
+               fprintf(stderr, "open_hca(%d)\n", tvdev->num);
+
        if (!config && tvdev->can_map) {
                int fd = open("/dev/mem", O_RDWR, O_SYNC);
                if (fd < 0) {
@@ -485,6 +488,9 @@ static int open_hca(struct tvdevice *tvd
 
 static void close_hca(void)
 {
+       if (verbose)
+               fprintf(stderr, "close_hca()\n");
+
        if (bar0)
                munmap(bar0, 1 << 20);
 }
@@ -563,6 +569,9 @@ static void flash_write_cmd(unsigned int
 
 static void flash_chip_reset(void)
 {
+       if (verbose)
+               fprintf(stderr, "flash_chip_reset()\n");
+
        /* Issue Flash Reset Command*/
        flash_write_cmd(0x0, 0xf0);
 }
@@ -784,6 +793,9 @@ static int flash_image_read_from_file(ch
        char *buf;
        unsigned int sector_sz;
 
+       if (verbose)
+               fprintf(stderr, "flash_image_read_from_file(%s)\n", fname);
+
        /* Open and read image files */
        fimg = fopen(fname, "r");
        if (fimg == NULL) {
@@ -872,6 +884,9 @@ static int flash_check_failsafe(void)
        char *psbuf;
        int i;
 
+       if (verbose)
+               fprintf(stderr, "flash_check_failsafe()\n");
+
        /* Grab the sector size first */
        sector_sz_ptr = (flash_byte_read(0x16) << 8) | flash_byte_read(0x17);
        sector_sz     = (flash_byte_read(0x32 + sector_sz_ptr) << 8) |
@@ -882,6 +897,8 @@ static int flash_check_failsafe(void)
         * than 1MB is suspicious and thrown out
         */
        if (sector_sz < 12 || sector_sz > 20) {
+               fprintf(stderr, "flash_check_failsafe(): sector_sz (%d) not"
+                               " valid. Set to zero.\n", sector_sz);
                failsafe.sector_sz = TV_FLASH_DEFAULT_SECTOR_SIZE;
                failsafe.valid     = 0;
                return 0;
@@ -1192,6 +1209,8 @@ static int identify_hca(int num, struct 
                case PCI_DEVICE_MELLANOX_MT25208_COMPAT:
                        printf("HCA #%d: Found MT25208 (MT23108 mode)", num);
                        break;
+               default:
+                       printf("HCA #%d: WTF? 0x%x", num, 
tvdev->pdev->device_id);
                }
 
                switch (identify_board(tvdev)) {
@@ -1236,7 +1255,10 @@ static int identify_hca(int num, struct 
                                                       ver_str,
                                                       
failsafe.images[0].vsd.data.vendor.topspin.hw_label);
                                } else
-                                       printf("  Primary image is valid, 
unknown source\n");
+                                       printf("  Primary image is valid, "
+                                               "unknown source (sig 
0x%x/0x%x)\n",
+                                               
failsafe.images[0].vsd.data.signature,
+                                               
failsafe.images[0].vsd.data.vendor.topspin.signature2);
                        } else
                                printf("  Primary image is NOT valid\n");
 
@@ -1257,7 +1279,10 @@ static int identify_hca(int num, struct 
                                                       ver_str,
                                                       
failsafe.images[1].vsd.data.vendor.topspin.hw_label);
                                } else
-                                       printf("  Secondary image is valid, 
unknown source\n");
+                                       printf("  Secondary image is valid,"
+                                               " unknown source (sig 
0x%x/0x%x)\n",
+                                               
failsafe.images[1].vsd.data.signature,
+                                               
failsafe.images[1].vsd.data.vendor.topspin.signature2);
                        } else
                                printf("  Secondary image is NOT valid\n");
                } else
@@ -1429,6 +1454,9 @@ static int flash_image_write_to_file(cha
        int i, fd;
        unsigned int offset;
 
+       if (verbose)
+               fprintf(stderr, "flash_image_write_to_file(%s)\n", fname);
+
        buffer = malloc(failsafe.sector_sz);
        if (!buffer) {
                fprintf(stderr, "couldn't allocated %d bytes of memory for 
buffer\n",
@@ -1460,12 +1488,10 @@ static int flash_image_write_to_file(cha
                }
 
                write(fd, buffer, failsafe.sector_sz);
-
                offset += failsafe.sector_sz;
        }
 
        close(fd);
-
        return 0;
 }
 
@@ -1474,6 +1500,9 @@ static int download_firmware(int hca, ch
        struct tvdevice *tvdev;
        int ret;
 
+       if (verbose)
+               fprintf(stderr, "download_firmware(%d,%s)\n", hca, ofname);
+
        tvdev = find_device(hca);
        if (!tvdev) {
                fprintf(stderr, "couldn't find HCA #%d on the PCI bus\n", hca);
_______________________________________________
openib-general mailing list
[email protected]
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to