1 /**********************************************************************
4 * Contact: support@cavium.com
5 * Please include "LiquidIO" in the subject.
7 * Copyright (c) 2003-2016 Cavium, Inc.
9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as
11 * published by the Free Software Foundation.
13 * This file is distributed in the hope that it will be useful, but
14 * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
16 * NONINFRINGEMENT. See the GNU General Public License for more details.
17 ***********************************************************************/
19 * @file octeon_console.c
21 #include <linux/moduleparam.h>
22 #include <linux/pci.h>
23 #include <linux/netdevice.h>
24 #include <linux/crc32.h>
25 #include "liquidio_common.h"
26 #include "octeon_droq.h"
27 #include "octeon_iq.h"
28 #include "response_manager.h"
29 #include "octeon_device.h"
30 #include "liquidio_image.h"
31 #include "octeon_mem_ops.h"
33 static void octeon_remote_lock(void);
34 static void octeon_remote_unlock(void);
35 static u64 cvmx_bootmem_phy_named_block_find(struct octeon_device *oct,
38 static int octeon_console_read(struct octeon_device *oct, u32 console_num,
39 char *buffer, u32 buf_size);
41 #define BOOTLOADER_PCI_READ_BUFFER_DATA_ADDR 0x0006c008
42 #define BOOTLOADER_PCI_READ_BUFFER_LEN_ADDR 0x0006c004
43 #define BOOTLOADER_PCI_READ_BUFFER_OWNER_ADDR 0x0006c000
44 #define BOOTLOADER_PCI_READ_DESC_ADDR 0x0006c100
45 #define BOOTLOADER_PCI_WRITE_BUFFER_STR_LEN 248
47 #define OCTEON_PCI_IO_BUF_OWNER_OCTEON 0x00000001
48 #define OCTEON_PCI_IO_BUF_OWNER_HOST 0x00000002
50 /** Can change without breaking ABI */
51 #define CVMX_BOOTMEM_NUM_NAMED_BLOCKS 64
53 /** minimum alignment of bootmem alloced blocks */
54 #define CVMX_BOOTMEM_ALIGNMENT_SIZE (16ull)
56 /** CVMX bootmem descriptor major version */
57 #define CVMX_BOOTMEM_DESC_MAJ_VER 3
58 /* CVMX bootmem descriptor minor version */
59 #define CVMX_BOOTMEM_DESC_MIN_VER 0
61 /* Current versions */
62 #define OCTEON_PCI_CONSOLE_MAJOR_VERSION 1
63 #define OCTEON_PCI_CONSOLE_MINOR_VERSION 0
64 #define OCTEON_PCI_CONSOLE_BLOCK_NAME "__pci_console"
65 #define OCTEON_CONSOLE_POLL_INTERVAL_MS 100 /* 10 times per second */
67 /* First three members of cvmx_bootmem_desc are left in original
68 * positions for backwards compatibility.
69 * Assumes big endian target
71 struct cvmx_bootmem_desc {
72 /** spinlock to control access to list */
75 /** flags for indicating various conditions */
80 /** incremented changed when incompatible changes made */
83 /** incremented changed when compatible changes made,
84 * reset to zero when major incremented
91 /** number of elements in named blocks array */
94 /** length of name array in bootmem blocks */
95 u32 named_block_name_len;
97 /** address of named memory block descriptors */
98 u64 named_block_array_addr;
101 /* Structure that defines a single console.
103 * Note: when read_index == write_index, the buffer is empty.
104 * The actual usable size of each console is console_buf_size -1;
106 struct octeon_pci_console {
108 u32 input_read_index;
109 u32 input_write_index;
110 u64 output_base_addr;
111 u32 output_read_index;
112 u32 output_write_index;
117 /* This is the main container structure that contains all the information
118 * about all PCI consoles. The address of this structure is passed to various
119 * routines that operation on PCI consoles.
121 struct octeon_pci_console_desc {
128 /* must be 64 bit aligned here... */
129 /* Array of addresses of octeon_pci_console structures */
130 u64 console_addr_array[];
131 /* Implicit storage for console_addr_array */
135 * This function is the implementation of the get macros defined
136 * for individual structure members. The argument are generated
137 * by the macros inorder to read only the needed memory.
139 * @param oct Pointer to current octeon device
140 * @param base 64bit physical address of the complete structure
141 * @param offset Offset from the beginning of the structure to the member being
143 * @param size Size of the structure member.
145 * @return Value of the structure member promoted into a u64.
147 static inline u64 __cvmx_bootmem_desc_get(struct octeon_device *oct,
152 base = (1ull << 63) | (base + offset);
155 return octeon_read_device_mem32(oct, base);
157 return octeon_read_device_mem64(oct, base);
164 * This function retrieves the string name of a named block. It is
165 * more complicated than a simple memcpy() since the named block
166 * descriptor may not be directly accessible.
168 * @param addr Physical address of the named block descriptor
169 * @param str String to receive the named block string name
170 * @param len Length of the string buffer, which must match the length
171 * stored in the bootmem descriptor.
173 static void CVMX_BOOTMEM_NAMED_GET_NAME(struct octeon_device *oct,
178 addr += offsetof(struct cvmx_bootmem_named_block_desc, name);
179 octeon_pci_read_core_mem(oct, addr, (u8 *)str, len);
183 /* See header file for descriptions of functions */
186 * Check the version information on the bootmem descriptor
189 * Exact major version to check against. A zero means
190 * check that the version supports named blocks.
192 * @return Zero if the version is correct. Negative if the version is
193 * incorrect. Failures also cause a message to be displayed.
195 static int __cvmx_bootmem_check_version(struct octeon_device *oct,
201 if (!oct->bootmem_desc_addr)
202 oct->bootmem_desc_addr =
203 octeon_read_device_mem64(oct,
204 BOOTLOADER_PCI_READ_DESC_ADDR);
205 major_version = (u32)__cvmx_bootmem_desc_get(
206 oct, oct->bootmem_desc_addr,
207 offsetof(struct cvmx_bootmem_desc, major_version),
208 sizeof_field(struct cvmx_bootmem_desc, major_version));
209 minor_version = (u32)__cvmx_bootmem_desc_get(
210 oct, oct->bootmem_desc_addr,
211 offsetof(struct cvmx_bootmem_desc, minor_version),
212 sizeof_field(struct cvmx_bootmem_desc, minor_version));
214 dev_dbg(&oct->pci_dev->dev, "%s: major_version=%d\n", __func__,
216 if ((major_version > 3) ||
217 (exact_match && major_version != exact_match)) {
218 dev_err(&oct->pci_dev->dev, "bootmem ver mismatch %d.%d addr:0x%llx\n",
219 major_version, minor_version,
220 (long long)oct->bootmem_desc_addr);
227 static const struct cvmx_bootmem_named_block_desc
228 *__cvmx_bootmem_find_named_block_flags(struct octeon_device *oct,
229 const char *name, u32 flags)
231 struct cvmx_bootmem_named_block_desc *desc =
232 &oct->bootmem_named_block_desc;
233 u64 named_addr = cvmx_bootmem_phy_named_block_find(oct, name, flags);
236 desc->base_addr = __cvmx_bootmem_desc_get(
238 offsetof(struct cvmx_bootmem_named_block_desc,
241 struct cvmx_bootmem_named_block_desc,
243 desc->size = __cvmx_bootmem_desc_get(oct, named_addr,
244 offsetof(struct cvmx_bootmem_named_block_desc,
247 struct cvmx_bootmem_named_block_desc,
250 strscpy(desc->name, name, sizeof(desc->name));
251 return &oct->bootmem_named_block_desc;
257 static u64 cvmx_bootmem_phy_named_block_find(struct octeon_device *oct,
263 if (!__cvmx_bootmem_check_version(oct, 3)) {
266 u64 named_block_array_addr = __cvmx_bootmem_desc_get(
267 oct, oct->bootmem_desc_addr,
268 offsetof(struct cvmx_bootmem_desc,
269 named_block_array_addr),
270 sizeof_field(struct cvmx_bootmem_desc,
271 named_block_array_addr));
272 u32 num_blocks = (u32)__cvmx_bootmem_desc_get(
273 oct, oct->bootmem_desc_addr,
274 offsetof(struct cvmx_bootmem_desc,
276 sizeof_field(struct cvmx_bootmem_desc,
279 u32 name_length = (u32)__cvmx_bootmem_desc_get(
280 oct, oct->bootmem_desc_addr,
281 offsetof(struct cvmx_bootmem_desc,
282 named_block_name_len),
283 sizeof_field(struct cvmx_bootmem_desc,
284 named_block_name_len));
286 u64 named_addr = named_block_array_addr;
288 for (i = 0; i < num_blocks; i++) {
289 u64 named_size = __cvmx_bootmem_desc_get(
292 struct cvmx_bootmem_named_block_desc,
295 struct cvmx_bootmem_named_block_desc,
298 if (name && named_size) {
300 kmalloc(name_length + 1, GFP_KERNEL);
304 CVMX_BOOTMEM_NAMED_GET_NAME(oct, named_addr,
307 if (!strncmp(name, name_tmp, name_length)) {
313 } else if (!name && !named_size) {
319 sizeof(struct cvmx_bootmem_named_block_desc);
326 * Find a named block on the remote Octeon
328 * @param name Name of block to find
329 * @param base_addr Address the block is at (OUTPUT)
330 * @param size The size of the block (OUTPUT)
332 * @return Zero on success, One on failure.
334 static int octeon_named_block_find(struct octeon_device *oct, const char *name,
335 u64 *base_addr, u64 *size)
337 const struct cvmx_bootmem_named_block_desc *named_block;
339 octeon_remote_lock();
340 named_block = __cvmx_bootmem_find_named_block_flags(oct, name, 0);
341 octeon_remote_unlock();
343 *base_addr = named_block->base_addr;
344 *size = named_block->size;
350 static void octeon_remote_lock(void)
352 /* fill this in if any sharing is needed */
355 static void octeon_remote_unlock(void)
357 /* fill this in if any sharing is needed */
360 int octeon_console_send_cmd(struct octeon_device *oct, char *cmd_str,
363 u32 len = (u32)strlen(cmd_str);
365 dev_dbg(&oct->pci_dev->dev, "sending \"%s\" to bootloader\n", cmd_str);
367 if (len > BOOTLOADER_PCI_WRITE_BUFFER_STR_LEN - 1) {
368 dev_err(&oct->pci_dev->dev, "Command string too long, max length is: %d\n",
369 BOOTLOADER_PCI_WRITE_BUFFER_STR_LEN - 1);
373 if (octeon_wait_for_bootloader(oct, wait_hundredths) != 0) {
374 dev_err(&oct->pci_dev->dev, "Bootloader not ready for command.\n");
378 /* Write command to bootloader */
379 octeon_remote_lock();
380 octeon_pci_write_core_mem(oct, BOOTLOADER_PCI_READ_BUFFER_DATA_ADDR,
382 octeon_write_device_mem32(oct, BOOTLOADER_PCI_READ_BUFFER_LEN_ADDR,
384 octeon_write_device_mem32(oct, BOOTLOADER_PCI_READ_BUFFER_OWNER_ADDR,
385 OCTEON_PCI_IO_BUF_OWNER_OCTEON);
387 /* Bootloader should accept command very quickly
388 * if it really was ready
390 if (octeon_wait_for_bootloader(oct, 200) != 0) {
391 octeon_remote_unlock();
392 dev_err(&oct->pci_dev->dev, "Bootloader did not accept command.\n");
395 octeon_remote_unlock();
399 int octeon_wait_for_bootloader(struct octeon_device *oct,
400 u32 wait_time_hundredths)
402 dev_dbg(&oct->pci_dev->dev, "waiting %d0 ms for bootloader\n",
403 wait_time_hundredths);
405 if (octeon_mem_access_ok(oct))
408 while (wait_time_hundredths > 0 &&
409 octeon_read_device_mem32(oct,
410 BOOTLOADER_PCI_READ_BUFFER_OWNER_ADDR)
411 != OCTEON_PCI_IO_BUF_OWNER_HOST) {
412 if (--wait_time_hundredths <= 0)
414 schedule_timeout_uninterruptible(HZ / 100);
419 static void octeon_console_handle_result(struct octeon_device *oct,
422 struct octeon_console *console;
424 console = &oct->console[console_num];
426 console->waiting = 0;
429 static char console_buffer[OCTEON_CONSOLE_MAX_READ_BYTES];
431 static void output_console_line(struct octeon_device *oct,
432 struct octeon_console *console,
434 char *console_buffer,
441 line = console_buffer;
442 for (i = 0; i < bytes_read; i++) {
443 /* Output a line at a time, prefixed */
444 if (console_buffer[i] == '\n') {
445 console_buffer[i] = '\0';
446 /* We need to output 'line', prefaced by 'leftover'.
447 * However, it is possible we're being called to
448 * output 'leftover' by itself (in the case of nothing
449 * having been read from the console).
451 * To avoid duplication, check for this condition.
453 if (console->leftover[0] &&
454 (line != console->leftover)) {
456 (*console->print)(oct, (u32)console_num,
459 console->leftover[0] = '\0';
462 (*console->print)(oct, (u32)console_num,
465 line = &console_buffer[i + 1];
469 /* Save off any leftovers */
470 if (line != &console_buffer[bytes_read]) {
471 console_buffer[bytes_read] = '\0';
472 len = strlen(console->leftover);
473 strscpy(&console->leftover[len], line,
474 sizeof(console->leftover) - len + 1);
478 static void check_console(struct work_struct *work)
480 s32 bytes_read, tries, total_read;
482 struct octeon_console *console;
483 struct cavium_wk *wk = (struct cavium_wk *)work;
484 struct octeon_device *oct = (struct octeon_device *)wk->ctxptr;
485 u32 console_num = (u32)wk->ctxul;
488 console = &oct->console[console_num];
493 /* Take console output regardless of whether it will
497 octeon_console_read(oct, console_num, console_buffer,
498 sizeof(console_buffer) - 1);
499 if (bytes_read > 0) {
500 total_read += bytes_read;
501 if (console->waiting)
502 octeon_console_handle_result(oct, console_num);
503 if (console->print) {
504 output_console_line(oct, console, console_num,
505 console_buffer, bytes_read);
507 } else if (bytes_read < 0) {
508 dev_err(&oct->pci_dev->dev, "Error reading console %u, ret=%d\n",
509 console_num, bytes_read);
513 } while ((bytes_read > 0) && (tries < 16));
515 /* If nothing is read after polling the console,
516 * output any leftovers if any
518 if (console->print && (total_read == 0) &&
519 (console->leftover[0])) {
520 /* append '\n' as terminator for 'output_console_line' */
521 len = strlen(console->leftover);
522 console->leftover[len] = '\n';
523 output_console_line(oct, console, console_num,
524 console->leftover, (s32)(len + 1));
525 console->leftover[0] = '\0';
528 delay = OCTEON_CONSOLE_POLL_INTERVAL_MS;
530 schedule_delayed_work(&wk->work, msecs_to_jiffies(delay));
533 int octeon_init_consoles(struct octeon_device *oct)
538 ret = octeon_mem_access_ok(oct);
540 dev_err(&oct->pci_dev->dev, "Memory access not okay'\n");
544 ret = octeon_named_block_find(oct, OCTEON_PCI_CONSOLE_BLOCK_NAME, &addr,
547 dev_err(&oct->pci_dev->dev, "Could not find console '%s'\n",
548 OCTEON_PCI_CONSOLE_BLOCK_NAME);
552 /* Dedicate one of Octeon's BAR1 index registers to create a static
553 * mapping to a region of Octeon DRAM that contains the PCI console
556 oct->console_nb_info.bar1_index = BAR1_INDEX_STATIC_MAP;
557 oct->fn_list.bar1_idx_setup(oct, addr, oct->console_nb_info.bar1_index,
559 oct->console_nb_info.dram_region_base = addr
560 & ~(OCTEON_BAR1_ENTRY_SIZE - 1ULL);
562 /* num_consoles > 0, is an indication that the consoles
565 oct->num_consoles = octeon_read_device_mem32(oct,
566 addr + offsetof(struct octeon_pci_console_desc,
568 oct->console_desc_addr = addr;
570 dev_dbg(&oct->pci_dev->dev, "Initialized consoles. %d available\n",
576 static void octeon_get_uboot_version(struct octeon_device *oct)
578 s32 bytes_read, tries, total_read;
579 struct octeon_console *console;
585 #define OCTEON_UBOOT_VER_BUF_SIZE 512
586 buf = kmalloc(OCTEON_UBOOT_VER_BUF_SIZE, GFP_KERNEL);
590 if (octeon_console_send_cmd(oct, "setenv stdout pci\n", 50)) {
595 if (octeon_console_send_cmd(oct, "version\n", 1)) {
600 console = &oct->console[console_num];
605 /* Take console output regardless of whether it will
609 octeon_console_read(oct,
610 console_num, buf + total_read,
611 OCTEON_UBOOT_VER_BUF_SIZE - 1 -
613 if (bytes_read > 0) {
614 buf[bytes_read] = '\0';
616 total_read += bytes_read;
617 if (console->waiting)
618 octeon_console_handle_result(oct, console_num);
619 } else if (bytes_read < 0) {
620 dev_err(&oct->pci_dev->dev, "Error reading console %u, ret=%d\n",
621 console_num, bytes_read);
625 } while ((bytes_read > 0) && (tries < 16));
627 /* If nothing is read after polling the console,
628 * output any leftovers if any
630 if ((total_read == 0) && (console->leftover[0])) {
631 dev_dbg(&oct->pci_dev->dev, "%u: %s\n",
632 console_num, console->leftover);
633 console->leftover[0] = '\0';
636 buf[OCTEON_UBOOT_VER_BUF_SIZE - 1] = '\0';
638 uboot_ver = strstr(buf, "U-Boot");
640 p = strstr(uboot_ver, "mips");
644 dev_info(&oct->pci_dev->dev, "%s\n", uboot_ver);
649 octeon_console_send_cmd(oct, "setenv stdout serial\n", 50);
652 int octeon_add_console(struct octeon_device *oct, u32 console_num,
658 struct delayed_work *work;
659 struct octeon_console *console;
661 if (console_num >= oct->num_consoles) {
662 dev_err(&oct->pci_dev->dev,
663 "trying to read from console number %d when only 0 to %d exist\n",
664 console_num, oct->num_consoles);
666 console = &oct->console[console_num];
668 console->waiting = 0;
670 coreaddr = oct->console_desc_addr + console_num * 8 +
671 offsetof(struct octeon_pci_console_desc,
673 console->addr = octeon_read_device_mem64(oct, coreaddr);
674 coreaddr = console->addr + offsetof(struct octeon_pci_console,
676 console->buffer_size = octeon_read_device_mem32(oct, coreaddr);
677 coreaddr = console->addr + offsetof(struct octeon_pci_console,
679 console->input_base_addr =
680 octeon_read_device_mem64(oct, coreaddr);
681 coreaddr = console->addr + offsetof(struct octeon_pci_console,
683 console->output_base_addr =
684 octeon_read_device_mem64(oct, coreaddr);
685 console->leftover[0] = '\0';
687 work = &oct->console_poll_work[console_num].work;
689 octeon_get_uboot_version(oct);
691 INIT_DELAYED_WORK(work, check_console);
692 oct->console_poll_work[console_num].ctxptr = (void *)oct;
693 oct->console_poll_work[console_num].ctxul = console_num;
694 delay = OCTEON_CONSOLE_POLL_INTERVAL_MS;
695 schedule_delayed_work(work, msecs_to_jiffies(delay));
697 /* an empty string means use default debug console enablement */
698 if (dbg_enb && !dbg_enb[0])
699 dbg_enb = "setenv pci_console_active 1";
701 ret = octeon_console_send_cmd(oct, dbg_enb, 2000);
710 * Removes all consoles
712 * @param oct octeon device
714 void octeon_remove_consoles(struct octeon_device *oct)
717 struct octeon_console *console;
719 for (i = 0; i < oct->num_consoles; i++) {
720 console = &oct->console[i];
722 if (!console->active)
725 cancel_delayed_work_sync(&oct->console_poll_work[i].
728 console->buffer_size = 0;
729 console->input_base_addr = 0;
730 console->output_base_addr = 0;
733 oct->num_consoles = 0;
736 static inline int octeon_console_free_bytes(u32 buffer_size,
740 if (rd_idx >= buffer_size || wr_idx >= buffer_size)
743 return ((buffer_size - 1) - (wr_idx - rd_idx)) % buffer_size;
746 static inline int octeon_console_avail_bytes(u32 buffer_size,
750 if (rd_idx >= buffer_size || wr_idx >= buffer_size)
753 return buffer_size - 1 -
754 octeon_console_free_bytes(buffer_size, wr_idx, rd_idx);
757 static int octeon_console_read(struct octeon_device *oct, u32 console_num,
758 char *buffer, u32 buf_size)
762 struct octeon_console *console;
764 if (console_num >= oct->num_consoles) {
765 dev_err(&oct->pci_dev->dev, "Attempted to read from disabled console %d\n",
770 console = &oct->console[console_num];
772 /* Check to see if any data is available.
773 * Maybe optimize this with 64-bit read.
775 rd_idx = octeon_read_device_mem32(oct, console->addr +
776 offsetof(struct octeon_pci_console, output_read_index));
777 wr_idx = octeon_read_device_mem32(oct, console->addr +
778 offsetof(struct octeon_pci_console, output_write_index));
780 bytes_to_read = octeon_console_avail_bytes(console->buffer_size,
782 if (bytes_to_read <= 0)
783 return bytes_to_read;
785 bytes_to_read = min_t(s32, bytes_to_read, buf_size);
787 /* Check to see if what we want to read is not contiguous, and limit
788 * ourselves to the contiguous block
790 if (rd_idx + bytes_to_read >= console->buffer_size)
791 bytes_to_read = console->buffer_size - rd_idx;
793 octeon_pci_read_core_mem(oct, console->output_base_addr + rd_idx,
794 (u8 *)buffer, bytes_to_read);
795 octeon_write_device_mem32(oct, console->addr +
796 offsetof(struct octeon_pci_console,
798 (rd_idx + bytes_to_read) %
799 console->buffer_size);
801 return bytes_to_read;
804 #define FBUF_SIZE (4 * 1024 * 1024)
805 #define MAX_BOOTTIME_SIZE 80
807 int octeon_download_firmware(struct octeon_device *oct, const u8 *data,
810 struct octeon_firmware_file_header *h;
811 char boottime[MAX_BOOTTIME_SIZE];
812 struct timespec64 ts;
819 if (size < sizeof(struct octeon_firmware_file_header)) {
820 dev_err(&oct->pci_dev->dev, "Firmware file too small (%d < %d).\n",
822 (u32)sizeof(struct octeon_firmware_file_header));
826 h = (struct octeon_firmware_file_header *)data;
828 if (be32_to_cpu(h->magic) != LIO_NIC_MAGIC) {
829 dev_err(&oct->pci_dev->dev, "Unrecognized firmware file.\n");
833 crc32_result = crc32((unsigned int)~0, data,
834 sizeof(struct octeon_firmware_file_header) -
836 if (crc32_result != be32_to_cpu(h->crc32)) {
837 dev_err(&oct->pci_dev->dev, "Firmware CRC mismatch (0x%08x != 0x%08x).\n",
838 crc32_result, be32_to_cpu(h->crc32));
842 if (memcmp(LIQUIDIO_BASE_VERSION, h->version,
843 strlen(LIQUIDIO_BASE_VERSION))) {
844 dev_err(&oct->pci_dev->dev, "Unmatched firmware version. Expected %s.x, got %s.\n",
845 LIQUIDIO_BASE_VERSION,
850 if (be32_to_cpu(h->num_images) > LIO_MAX_IMAGES) {
851 dev_err(&oct->pci_dev->dev, "Too many images in firmware file (%d).\n",
852 be32_to_cpu(h->num_images));
856 dev_info(&oct->pci_dev->dev, "Firmware version: %s\n", h->version);
857 snprintf(oct->fw_info.liquidio_firmware_version, 32, "LIQUIDIO: %s",
860 data += sizeof(struct octeon_firmware_file_header);
862 dev_info(&oct->pci_dev->dev, "%s: Loading %d images\n", __func__,
863 be32_to_cpu(h->num_images));
864 /* load all images */
865 for (i = 0; i < be32_to_cpu(h->num_images); i++) {
866 load_addr = be64_to_cpu(h->desc[i].addr);
867 image_len = be32_to_cpu(h->desc[i].len);
869 dev_info(&oct->pci_dev->dev, "Loading firmware %d at %llx\n",
870 image_len, load_addr);
872 /* Write in 4MB chunks*/
881 /* download the image */
882 octeon_pci_write_core_mem(oct, load_addr, data, (u32)size);
890 /* Pass date and time information to NIC at the time of loading
891 * firmware and periodically update the host time to NIC firmware.
892 * This is to make NIC firmware use the same time reference as Host,
893 * so that it is easy to correlate logs from firmware and host for
896 * Octeon always uses UTC time. so timezone information is not sent.
898 ktime_get_real_ts64(&ts);
899 ret = snprintf(boottime, MAX_BOOTTIME_SIZE,
900 " time_sec=%lld time_nsec=%ld",
901 (s64)ts.tv_sec, ts.tv_nsec);
902 if ((sizeof(h->bootcmd) - strnlen(h->bootcmd, sizeof(h->bootcmd))) <
904 dev_err(&oct->pci_dev->dev, "Boot command buffer too small\n");
907 strncat(h->bootcmd, boottime,
908 sizeof(h->bootcmd) - strnlen(h->bootcmd, sizeof(h->bootcmd)));
910 dev_info(&oct->pci_dev->dev, "Writing boot command: %s\n",
913 /* Invoke the bootcmd */
914 ret = octeon_console_send_cmd(oct, h->bootcmd, 50);
916 dev_info(&oct->pci_dev->dev, "Boot command send failed\n");