Skip to content

Commit

Permalink
liquidio: show NIC's U-Boot version in a dev_info() message
Browse files Browse the repository at this point in the history
Signed-off-by: Weilin Chang <[email protected]>
Signed-off-by: Felix Manlunas <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Weilin Chang authored and davem330 committed Aug 29, 2017
1 parent 7e3108f commit b6eb9d5
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions drivers/net/ethernet/cavium/liquidio/octeon_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,82 @@ int octeon_init_consoles(struct octeon_device *oct)
return ret;
}

static void octeon_get_uboot_version(struct octeon_device *oct)
{
s32 bytes_read, tries, total_read;
struct octeon_console *console;
u32 console_num = 0;
char *uboot_ver;
char *buf;
char *p;

#define OCTEON_UBOOT_VER_BUF_SIZE 512
buf = kmalloc(OCTEON_UBOOT_VER_BUF_SIZE, GFP_KERNEL);
if (!buf)
return;

if (octeon_console_send_cmd(oct, "setenv stdout pci\n", 50)) {
kfree(buf);
return;
}

if (octeon_console_send_cmd(oct, "version\n", 1)) {
kfree(buf);
return;
}

console = &oct->console[console_num];
tries = 0;
total_read = 0;

do {
/* Take console output regardless of whether it will
* be logged
*/
bytes_read =
octeon_console_read(oct,
console_num, buf + total_read,
OCTEON_UBOOT_VER_BUF_SIZE - 1 -
total_read);
if (bytes_read > 0) {
buf[bytes_read] = '\0';

total_read += bytes_read;
if (console->waiting)
octeon_console_handle_result(oct, console_num);
} else if (bytes_read < 0) {
dev_err(&oct->pci_dev->dev, "Error reading console %u, ret=%d\n",
console_num, bytes_read);
}

tries++;
} while ((bytes_read > 0) && (tries < 16));

/* If nothing is read after polling the console,
* output any leftovers if any
*/
if ((total_read == 0) && (console->leftover[0])) {
dev_dbg(&oct->pci_dev->dev, "%u: %s\n",
console_num, console->leftover);
console->leftover[0] = '\0';
}

buf[OCTEON_UBOOT_VER_BUF_SIZE - 1] = '\0';

uboot_ver = strstr(buf, "U-Boot");
if (uboot_ver) {
p = strstr(uboot_ver, "mips");
if (p) {
p--;
*p = '\0';
dev_info(&oct->pci_dev->dev, "%s\n", uboot_ver);
}
}

kfree(buf);
octeon_console_send_cmd(oct, "setenv stdout serial\n", 50);
}

int octeon_add_console(struct octeon_device *oct, u32 console_num,
char *dbg_enb)
{
Expand Down Expand Up @@ -611,6 +687,8 @@ int octeon_add_console(struct octeon_device *oct, u32 console_num,

work = &oct->console_poll_work[console_num].work;

octeon_get_uboot_version(oct);

INIT_DELAYED_WORK(work, check_console);
oct->console_poll_work[console_num].ctxptr = (void *)oct;
oct->console_poll_work[console_num].ctxul = console_num;
Expand Down

0 comments on commit b6eb9d5

Please sign in to comment.